hi all, hi martin
as pointed out in a previous thread, it's tricky to use [tcp*] object classes for transporting packet oriented protocols, such as OSC or FUDI. when dealing with [tcpserver], the situation gets even more tricky. when several clients are connected to a [tcpserver] and they all send data in a packet oriented protocol simultaneously, the packets from several sockets might get mixed up on the server side, since tcp is not packet-aware and frames sent by clients might get splitted (or even concatenated). the only way i found to overcome that problem, was to make [tcpserver] protocol-aware, so that it keeps track of the several incoming streams and creates protocol-compliant packets out of them. on the other hand, i wanted a generic solution, that could be extended with support for more protocols than initally implemented. that is why i made:
[tcpsocketserver <protocol> <port>]
from what i understand, it works the same way, as other servers for a packet-oriented protocol work. whenever a new client connects, [tcpsocketserver] dynamically creates an instance of a socket handler, an abstraction, that is called [ŧcpsocket.PROTOCOLNAME]. all data received on that socket is sent to the appropriate handler. the handler contains the code, that forms proper packets from the incoming stream and sends the packets back to [tcpsocketserver]. no matter in what order and in what frame sizes the streams are received, [tcpsocketserver] only outputs valid, protocol-compliant packets.
yet, two protocols are supported: OSC and FUDI. support for the protocol FOO can be added by creating another socket handler, naming it tcpsocket.FOO.pd and putting in the code, that makes FOO-packets out of the incomding stream. then it can be called with [tcpsocketserver FOO 1234].
i hope this all makes sense to you. comments are welcome, of course. if you, martin, find it useful, i'd be glad, if this could make it into the mrpeach library.
my main purpose for doing this was to be able to transmit OSC packets in a multiclient<->server environment, which is finally working well since [tcpsocketserver].
http://www.romanhaefeli.net/software/pd/tcpsocketserver.tar.gz
roman
___________________________________________________________ Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de