> If I got you right, an open UPD Socket is always a server socket by
default, that accepts requests from any IP source address, as long as the
PORT is matching?
>
> And I always have to filter the incoming datagrams with GetRemoteSinIP to
establish a point-to-pont connection?

In most common scenarios you are acting as:

1) UDP server - Bind to local port. When you receive a datagram, next
sending operation send datagram back as reply.

2) UDP client - Connect to remote address and port. Send query
datagram to remote server and next Recv operation reads server reply.

See, you not need any special handling in these typical scenarios. If
you need to have point-to-point channel and send/receive data
randomly, isn't TCP stream better solution?

BTW: UDP is dataram based, it is not a byte stream. So, you need to
read full datagram, not just a first byte. Take a look for RecvPacket
method, even you wish just first byte from the datagram.




I only need to transmit one data byte every 50ms (status of 8 relays)
So it is just a datagram with one byte payload. TCP is too heavy for this.

Following your reply I tried this:
1) Without using the BIND('0.0.0.0',PORT) methode, just
CONNECT(remoteIP,PORT) : I am not having any connectivity
2) binding to the remoteIP BIND(remoteIP,PORT) and CONNECT(remoteIP,PORT) :
I am not having connectivity, netstat shows that the socket is bound to
0.0.0.0:with random Port number

The only way for a PtP is to BIND('0.0.0.0',PORT) CONNECT(remoteIP,PORT) on
both ends and then filter the received datagram with GetRemoteSinIP ?

It works as expected, but it seems to me that I have then a server socket on
both ends?

And I was just discovering this on the Internet:
Unlike TCP, the UDP is not point-to-point. For example, several hosts can
send the datagrams to the same socket of your device- and all of them can be
accepted- a situation that is impossible with TCP.

Now it's clear for me!



_______________________________________________
synalist-public mailing list
synalist-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/synalist-public

Reply via email to