Your stream-based protocol should work roughly as follows:
Please note that the protocol number for your protocol should be proto.IP_CS333TCP, not the protocol number of 6 used for normal TCP.import proto import ip ... ip.register_protocol(proto.IP_CS333TCP, tcp_handler)
On success, the function should return nothing. Otherwise, it should print an error if a connection could not be established for some reason.connect(s,("nlab-1",8888))
This function blocks until the packet is successfully sent. If the packet can not be sent for some reason (unknown host), an error should be returned. Otherwise, the actual number of bytes sent should be returned.sendto(s,"Hello",("192.168.69.4",1234))
close(s). Closes the socket. This should clear the socket's address, incoming data queue, and remove the socket's port number from any internal port tables. Once closed, sockets should not be reused.