TCP Stream Objects -- Python library reference



Next: TCP Status Objects Prev: mactcp Up: mactcp Top: Top

14.9.1. TCP Stream Objects

asr -- attribute of TCP stream
When set to a value different than None this should point to a function with two integer parameters: an event code and a detail. This function will be called upon network-generated events such as urgent data arrival. In addition, it is called with eventcode MACTCP.PassiveOpenDone when a PassiveOpen completes. This is a Python addition to the MacTCP semantics. It is safe to do further calls from the asr.
PassiveOpen (port) -- Method on TCP stream
Wait for an incoming connection on TCP port port (zero makes the system pick a free port). The call returns immediately, and you should use wait to wait for completion. You should not issue any method calls other than wait, isdone or GetSockName before the call completes.
wait () -- Method on TCP stream
Wait for PassiveOpen to complete.
isdone () -- Method on TCP stream
Return 1 if a PassiveOpen has completed.
GetSockName () -- Method on TCP stream
Return the TCP address of this side of a connection as a 2-tuple (host, port), both integers.
ActiveOpen (lport, host, rport) -- Method on TCP stream
Open an outgoing connection to TCP address (host, rport). Use local port lport (zero makes the system pick a free port). This call blocks until the connection has been established.
Send (buf, push, urgent) -- Method on TCP stream
Send data buf over the connection. Push and urgent are flags as specified by the TCP standard.
Rcv (timeout) -- Method on TCP stream
Receive data. The call returns when timeout seconds have passed or when (according to the MacTCP documentation) ``a reasonable amount of data has been received''. The return value is a 3-tuple (data, urgent, mark). If urgent data is outstanding Rcv will always return that before looking at any normal data. The first call returning urgent data will have the urgent flag set, the last will have the mark flag set.
Close () -- Method on TCP stream
Tell MacTCP that no more data will be transmitted on this connection. The call returns when all data has been acknowledged by the receiving side.
Abort () -- Method on TCP stream
Forcibly close both sides of a connection, ignoring outstanding data.
Status () -- Method on TCP stream
Return a TCP status object for this stream giving the current status (see below).


Next: TCP Status Objects Prev: mactcp Up: mactcp Top: Top