Socket stuff

Dar Scott dsc at swcp.com
Mon Mar 18 13:15:01 EST 2002


On Monday, March 18, 2002, at 09:44 AM, JohnRule at aol.com wrote:

> I do not have this problem with other 'maintained'
> TCP socket connections for other net devices...only between computers.
>
> Is my concept wrong?

I'm going to take a stab in the dark concerning what may be wrong.  
Here are some comments regarding TCP.

The two ends of a TCP connection are not the same.  One end 
initiates the connection.  In the socket model, this difference is 
emphasized more.

The end that initiates the connection is often called the client.  
The other is the server.

The TCP server "listens" for connections on a port and, when a 
request comes in, it may "accept" it and create a new socket to go 
with the connection.  It may have more than one connection and thus 
more than one socket on that port.  The remote address and port 
makes them unique.

When you connect to "other net devices", you are probably 
connecting as a client.  You would be using the Revolution command 
"open socket".

You can connect to another Revolution application the same way.  
However, the other end must be a server.  You open that with 
accept.  The accept spawns an opening of a new socket whenever a 
request comes in.  There is no attempt to open one for 
communication until then.  Since you have no socket handle until 
the connection comes in, you cannot write until a connection is 
made.  And it would make no sense to do so.

Writing the server end takes a little bit of more work than writing 
the client end, especially if you want to handle more than one 
client.

A simple trick of using two connections can be used to make the 
link between two applications symetrical.

An alternate TCP/IP protocol is the UDP protocol.  This allows you 
to send entire messages (not just bytes in a stream) to some port 
on some computer.  Your application may organize this as if it was 
a connection.  So, in principle, there is no reason why both ends 
could not be opened with "open".  Practice may vary.

Caveat:  I have been experimenting with UDP on Revolution, but yet 
have only read the documents on TCP on Revolution.  I do have TCP 
experience in other environments.

I hope this helps and that I haven't gone down some bunny trail 
that doesn't apply.

Dar Scott






More information about the use-livecode mailing list