the setting: want write point-to-point connection
class that, when used, not differentiate between server , client. first host calls connect()
shall become server waiting client connect , second shall become client connects server.
in order connect()
method first needs check listening server. a) first time happens no server found , party calling connect()
starts listening on localhost
, configured port incoming connection. b) second party calling connect()
checks remote host on given port, recognizes server , connects it.
this not hard using tcp since tcpclient.connect()
throws exception when no connection established. therefore know when i'm first. since use reliable lan only, wanted use udp, however.
my problem: how can determine whether udp server socket waiting incoming data.
ideally use asynchronous network api directly afterwards. instead of dealing listening threads myself.
with udp, communication model akin message in bottle: know sent it, there's no way know if ever received it.
you need manually establish communication protocol determine if remote party listening (e.g. have them send "yes, 'm here" response). require both endpoints accept udp datagrams.
Comments
Post a Comment