287
TIDE and Tibbo BASIC User Manual
©2000-2008 Tibbo Technology Inc.
Incoming TCP connection to port 1001
from host 192.168.100.40:29600
Connection will be accepted on socket
0 since this socket lists 1001 as one of
the listening ports and this incoming
connection request is from "correct"
host.
Incoming TCP connection to port 1001
from host 192.168.100.40:29601
This will be taken as a reconnect on
socket 0: this incoming connection is
from the same host as the previous
one and it targets the same port 1001.
Incoming TCP connection to port 1001
from host 192.168.100.41:900
Connection will be accepted on socket
1, because socket 0 is already
engaged in a connection and this new
connection request cannot be
intepreted as a reconnect (different
host).
Incoming UDP datagram to port 2000
from host 192.168.100.40:320
This datagram will be accepted on
socket 2 and "connection" will be
opened.
Establishing Outgoing Connections
Performing active opens
Now that we know how to setup the sockets to accept incoming TCP connections
and UDP "connections" we move on to learning about establishing connections of
our own, or, as is often said, performing "active opens".
Establishing an outgoing connection is always an explicit action- you use the
method to attempt to do this. Once you do this the socket will try to
perform an active open to the IP and port specified by the
and
properties. There is also a
property --
this one defines which network interface the new connection will be passing
through.
As you can see, the sock.targetip and sock.targetport properties
perform a double-duty: for incoming connections they define (if
required by the
) who will be able to connect to the
socket. For outgoing connections this pair defines IP and host to which
the socket will attempt to connect.
Notice, that your sock.connect invocation will only work if you do this while the
socket is in the "closed" state (see
).
Active opens for TCP
Once you tell a "TCP" socket to connect, the socket will do the following:
Resolve the IP address of the target using the ARP protocol.
Attempt to engage the target in a standard TCP connection sequence (SYN-SYN-
ACK).
Connection will be either established, or this will fail. Your program has a way to
monitor this- see
.
330
359
360
359
338
292
292