Net-Objects Client/Server Library

User contributed sources that have become inactive, deprecated, or generally unusable. But ... we don't really want to throw them away either.
vdecampo
Posts: 2992
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Net-Objects Client/Server Library

Post by vdecampo »

I am posting the initial release of my Net Objects library.

What is it?

Net Objects builds upon the chisock library created by cha0s to implement non-blocking calls, events and multi-threaded sending & receiving.

What was it designed for?

Net Objects was built with the idea of transmitting binary data like UDTs or Audio/Video. I envision it to be an excellent way to create network client/servers for games and applications.

How many connections does the server allow?

The Server Object is currently hard coded at a max index of 10 which would be 11 concurrent connections indexed from 0 to 10.


I have only made 3 small demos of its usage and I would really appreciate it if anyone could provide some more. There is currently no official documentation but I will be posting some details on this thread shortly.

Download it here...
Net Objects (692k)

Enjoy
-Vince
Last edited by vdecampo on Jan 10, 2012 13:54, edited 3 times in total.
vdecampo
Posts: 2992
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Post by vdecampo »

Here is a sample of creating a basic server app.

Main Code

Code: Select all

Dim As _NET_OBJECT_SERVER NOS = _NET_OBJECT_SERVER(10000,10000)

   With NOS
      .SetCallback @callback
      .SetEOL Chr(13,10)      
      .AppendEOL = 1
      .Listen (7000)
   End With

   Do
      Sleep 3
   Loop Until InKey=Chr(27)
   
   NOS.Disconnect
Then the callback handles the events...

Code: Select all

Sub callback(conidx As Integer, msgcode As Integer, NOS As _NET_OBJECT_SERVER Ptr)
   
   With *NOS
   
      Select Case msgcode
         Case .sktCONNECTED
            Print "Client Connected: " & NOS->ClientIP(conidx)
            NOS->SendData(conidx,"HELLO")
         Case .sktDISCONNECTED
            Print "Client Disconnected: " & NOS->ClientIP(conidx)
         Case .sktSENDFAIL
         Case .sktDNSFAIL
         Case .sktEOL
         Case .sktDATAIN
            If NOS->IsEOL(conidx) Then
               Print "Data Received from: " & NOS->ClientIP(conidx)
               Print NOS->GetString(conidx)
            End if                       
         Case .sktRxOVERFLOW
         Case .sktTxOVERFLOW
      End Select

   End With
   
End Sub
-Vince
vdecampo
Posts: 2992
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Post by vdecampo »

SERVER OBJECT

Constructor (in_buffsize As Integer,out_buffsize As Integer)

Methods

Function GetVersion () As String
- Returns the version of the server object library (xx.xx.xx)

Function Listen (ip_port As Integer) As Integer
- Tells the server to listen and accept incoming connections on the specified port

Function Disconnect (ConIdx As Integer=-1) As Integer
- Disconnets a client connection. If ConIdx is not specified, ALL connections are terminated

Function IsConnected (ConIdx As Integer=-1) As Integer
- Returns non-zero if there is a connection for the specified connection index. If ConIdx is not specified, any connections will return a non-zero value.

Function Connections () As Integer
- Returns the number of active connections

Function ClientIP (ConIdx As Integer) As String
- Returns the Client IP Address for the specified connection index.

Function GetString (ConIdx As Integer, strsize As Integer=0) As String
- Returns a string from the receive buffer. If strsize is omitted, then the string will be up to the next occurance of the EOL character sequence. If there is no EOL sequence specified, then the entire buffer is returned.

Function GetBytes (ConIdx As Integer, size As Integer=0) As Any Ptr
- Returns a pointer to a buffer with [size] bytes from the receive buffer. If size is omitted, then the buffer size will be up to the next occurance of the EOL character sequence. If there is no EOL sequence specified, then the entire buffer is returned.

Function IsEOL (ConIdx As Integer) As Integer
- Returns non-zero if the EOL character sequence appears in the receive buffer.

Function SendData Overload (ConIdx As Integer, pdata As Any Ptr, dsize As Integer) As Integer
- Sends binary data to the transmit buffer for the specified connection index.

Function SendData Overload (ConIdx As Integer, pdata As String) As Integer
- Sends string data to the transmit buffer for the specified connection index.

Function ResolveIP (domain As String) As String
- Uses the DNS service to resolve a domain name to an IP address

Sub SetCallback (fptr As Any Ptr)
- Sets the pointer to the callback function used to receive events

Sub SetEOL (new_eol As String)
- Sets the End-of-Line character sequence to use when reading/writing information.

Properties

ReturnEOL As Integer = 0
- Set to 1 if you want the EOL characters to be included when you retrieve information from the receive buffer

AppendEOL As Integer = 0
- Set to 1 if you want the EOL characters to be automatically added when you send information to the transmit buffer

Events

sktCONNECTED
- Fired when a connection is made
sktDISCONNECTED
- Fired when a connection is terminated
sktSENDFAIL
- Fired if data fails to be sent
sktDNSFAIL
- Fired if DNS fails to resolve
sktEOL
- (NOT WORKING)
sktDATAIN
- Fired when data is received
sktRxOVERFLOW
- Fired if too much data is in the receive buffer (See constructor)
sktTxOVERFLOW
- Fired if too much data is in the transmit buffer (See constructor)

Constants

FTP_DATA = 20
FTP_CONTROL = 21
SSH = 22
TELNET = 23
GOPHER = 70
HTTP = 80
SFTP = 115
IRC = 6667

Callback

callback As Sub (ConIdx As Integer, msgcode As Integer, NOS As _NET_OBJECT_SERVER Ptr)
Last edited by vdecampo on Apr 15, 2009 14:19, edited 1 time in total.
vdecampo
Posts: 2992
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Post by vdecampo »

CLIENT OBJECT

Constructor (in_buffsize As Integer,out_buffsize As Integer)

Methods


Function GetVersion () As String
- Returns the version of the server object library (xx.xx.xx)

Function Connect () As Integer
- Attempts a connection using the set IP address and port

Function Disconnect () As Integer
- Disconnets the client connection.

Function IsConnected () As Integer
- Returns non-zero if there is a connection.

Function GetString (strsize As Integer=0) As String
- Returns a string from the receive buffer. If strsize if omitted, then the string will be up to the next occurance of the EOL character sequence. If there is no EOL sequence specified, then the entire buffer is returned.

Function GetBytes (size As Integer=0) As Any Ptr
- Returns a pointer to a buffer with [size] bytes from the receive buffer. If size if omitted, then the buffer size will be up to the next occurance of the EOL character sequence. If there is no EOL sequence specified, then the entire buffer is returned.

Function IsEOL () As Integer
- Returns non-zero if the EOL character sequence appears in the receive buffer.

Function SendData Overload (pdata As Any Ptr, dsize As Integer) As Integer
- Sends binary data to the transmit buffer for the specified connection index.

Function SendData Overload (pdata As String) As Integer
- Sends string data to the transmit buffer for the specified connection index.

Function ResolveIP (domain As String) As String
- Uses the DNS service to resolve a domain name to an IP address

Sub SetCallback (fptr As Any Ptr)
- Sets the pointer to the callback function used to receive events

Sub SetEOL (new_eol As String)
- Sets the End-of-Line character sequence to use when reading/writing information.

Function GetHttpHdr () As String
- Specialized function to retreive the HTTP header to a string

Sub SetAddress (ipadd As String) '->XXX.XXX.XXX.XXX:PORT
- Sets the target IP address for the connection. You can optionally set the port here or with the separate SetPort function

Sub SetPort (ip_port As Integer)
- Sets the port for the target connection.

Sub HttpReq (req As String)
- Sends an HTTP request to a web server.
(ex: "www.imakegames.com/files/logo.jpg" to retreive the image file logo.jpg)


Events

sktCONNECTING
- Fired when a connection attempt is in progress
sktCONNECTED
- Fired when a connection is made
sktDISCONNECTED
- Fired when a connection is terminated
sktSENDFAIL
- Fired if data fails to be sent
sktDNSFAIL
- Fired if DNS fails to resolve
sktEOL
- (NOT WORKING)
sktDATAIN
- Fired when data is received
sktRxOVERFLOW
- Fired if too much data is in the receive buffer (See constructor)
sktTxOVERFLOW
- Fired if too much data is in the transmit buffer (See constructor)

Constants

FTP_DATA = 20
FTP_CONTROL = 21
SSH = 22
TELNET = 23
GOPHER = 70
HTTP = 80
SFTP = 115
IRC = 6667

Callback

callback As Sub (msgcode As Integer, NOC As _NET_OBJECT_CLIENT Ptr)
Imortis
Moderator
Posts: 1924
Joined: Jun 02, 2005 15:10
Location: USA
Contact:

Post by Imortis »

This looks great. I can't wait to try it out.
AGS
Posts: 1284
Joined: Sep 25, 2007 0:26
Location: the Netherlands

Post by AGS »

The PDF files that came with the package had this nasty 'watermark' on them. So I thought: let's get rid of that.

PDF files without watermark (+Open Office documents used to create the PDF files) can be downloaded here

Nice piece of software, this client - server - implementation.

I'm wondering if I could get one client asking the server for the index page of the online FB manual (wiki) and get that same client to parse that index page. That same client could then send pagerequests to the server (one for every page in the wiki) while another client would be asking the server for the actual content of the pages.

One server, two clients. Or perhaps one server, many clients. Letting more clients connect to the server and let each pick up pages and convert them (to... Latex for example?). The client that finishes converting a page first will get the next available page.

Would the above use of the client - server - package work?
Oz
Posts: 586
Joined: Jul 02, 2005 14:21
Location: Waterloo, Ontario, Canada
Contact:

Post by Oz »

It would be a tad bit nicer if there wasn't a hard-coded limit for the number of connections. Maybe a pointer-array?
vdecampo
Posts: 2992
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Post by vdecampo »

AGS wrote:One server, two clients. Or perhaps one server, many clients. Letting more clients connect to the server and let each pick up pages and convert them (to... Latex for example?). The client that finishes converting a page first will get the next available page.
When you say server are you talking about a Web server or the server object? You can certainly have more than one client object running at same time. I am currently working on a combination server/client version of tic-tac-toe as a sample for this project.

@Oz

Yes, that was done just to make things move along a little faster. While it is very easy to up this limit, I don't see a problem changing it to more dynamic functionilty.

FYI: I have made some changes to the initial library to allow them to co-exist in the same project. I will post these changes shortly.

-Vince
nobozoz
Posts: 238
Joined: Nov 17, 2005 6:24
Location: Chino Hills, CA, USA

Post by nobozoz »

Vince,

I'd like to experiment with your Net_Object examples, but I can't download cha0s' chisock library (latest version is 08-24-09 ?). It looks like cha0s' old site has been abandoned, but the new site is incomplete.

Jim (nobozoz)
vdecampo
Posts: 2992
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Post by vdecampo »

@nobozoz

You can grab it from my web site here...

Chisock Library by Chaos (8-24-2008)

-Vince
nobozoz
Posts: 238
Joined: Nov 17, 2005 6:24
Location: Chino Hills, CA, USA

Post by nobozoz »

Thank you. Just what I needed.
attacke
Posts: 55
Joined: Mar 19, 2006 11:57
Contact:

Post by attacke »

i seem to be missing the fifo.bi file, i downloaded the one from here but that dont have the saveBuffer() function.
vdecampo
Posts: 2992
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Post by vdecampo »

You can download the latest version of FIFO from here...

FIFO Buffer

-Vince
creek23
Posts: 261
Joined: Sep 09, 2007 1:57
Location: Philippines
Contact:

Re: Net-Objects Client/Server Library

Post by creek23 »

Hi Vince,

Do you happen to still have a copy of NetObject?

~creek23
vdecampo
Posts: 2992
Joined: Aug 07, 2007 23:20
Location: Maryland, USA
Contact:

Re: Net-Objects Client/Server Library

Post by vdecampo »

Yes, try here...

Net-Objects

-Vince
Last edited by vdecampo on Jan 10, 2012 18:11, edited 2 times in total.
Post Reply