Socket UDP + same port number

Hello guys,

A question for you.

I have a server as UDP and the clients will try connect using the same server port with, of course, a different socket 0 ~ 8.

Is it possible ?

Thank you for your help.

Andre ribeiro

W5500 configured as UDP server or client?
Re-reading your other post like this [url]Step-by-Step UDP implementation] I saw that you used DHCP libraries so if you are using the W5500 as a client you can use the part of prepare, send and receiving packets of the same example.
UDP streams do not need a connection and contain the caller’s information in the first few bytes of the stream so you can open multiple socket for receiving (W5500 with single IP / MAC with one or more socket on the same port ) and you know who’s calling and on what (client side) port answer.
Using W5500 as UDP multisocket server is possible for small one-shot stream and very difficult for countinuos stream.
UDP is made to individual packages of small dimensions because is not guaranteed the packets reception order.
So in case of UDP flows in addition to mark each package uniquely (using other type of protocols for continuous streaming ex RDP ) you must manage them in memory before you can use.
Everything depends on the size flow you want to achieve.

Hello Coccoliso and thank you for your reply.

Yes, I am using part of send and receive example (loopback example) to run my application.
In fact, my question is more about networks’ concepts, etc.


Each socket must be using a different port from others ?
In my network, if I have a master (my application), each client must use a different socket or a different socket ??

TCP ou UDP ?? I know a little the difference between these types.

And yes … I will read a lot about this from now …

Thank you

maybe it’s time to make some clarifications.
Sockets are bidirectional communication channels and W5500 there are 8.
Sockets can be opened independently for listening (and are used in server applications) or sending (and used in client applications).
In W5500 (as the other chips) each socket can be opened as a client or server independently at the same time.
The difference between client and server is then due only to the one who initiates communication because once communication is established clients and servers talk to each other in both directions.
The difference between TCP and UDP is substantial, since TCP requires a connection that remains until one of the two side (client or server) make a disconnection … while UDP not have a connection then the single package is not part of a flow and there is no guarantee your order of arrival without a different system (which must make by user protocol) for the enumeration of outcoming/incoming packages.
Then you enter the part relating to the ports: outside of the known ports (see 80, 8080 and some other) routers prevent incoming communication unless they open manually it then a server application must first tested in LAN.
So from the above I prefer a TCP communication which with a protocol that qualifies possible transfer errors (SOAP in the case of HTTP or MQTT in case of short messages).

Hello and good morning

Thank you so much for your class … really thank you.
and about the MQTT … it seems perfect for my application that I am using short messages. thank you so much for it.

Do you have any library where yo use it ?

thanks a lot.

I recognize to be “a fish out of water” but I have experience in PIC (8 to 32) and use a basic compiler to get the HEX so if you hear and you are able to return it in the form that you like :
PIC18 W5500 library is here : [url][/url]
PIC18 MQTT/W5500 library is here : [url][/url]
PIC24 W5500 library is here : [url][/url]
PIC24 MQTT/W5500 library is here : [url][/url]
The compiler I use is modular and therefore very scalable and is based on what was done by David J.Barker in
Swordish ([url][/url]) and Firewing ([url][/url])
You find examples of applications written in VB.NET for SOAP and how try the MQTT library with sender and reader applications.
That’s it and I think that working there is enough if you’re interested :wink:

Hello coccoliso …

Thank you so much. I will take a look in the files you sent me and I fell it will fit my needs a lot.

I will keep you on touch as soon as I am developing the solution.

once again … thank you so much.


regarding MQTT need to be a little more precise … it is the equivalent of dated MQ queues that now can also be operated remotely via the Internet.
You need a server which receives and then distributes the messages to connected clients.
Luckily a number of open source developers have created server (which in MQTT are called brokers) that can fit on any OS (also phones and tablets)and brokers available directly on internet (accidents :open_mouth: ) so you can connect from anywhere in the world for free :smiley: so we say that we are really in the “internet of things”


you mean MQTT has some dependency from worldwide servers or brokers ?

Is it ok if I use into a intranet where I will use a PC (client) and a device (server) connected in the same network ?

I loved it when you told me it is a protocol over tcp ip that qualifies possible transfer errors for short messages.
My server will take TCP packets, from Pc and cell phone) and distribute over the other devices connected to this device (master).
I was wondering in ue MQTT also to talk with these others devices … sensors and meters devices.

Thank you so much for your help as always.


You can host the broker in your home and with only an opened port in router show it in internet else use a public broker… as you want.

Hi Cocoliso… .

thank you …
helpfull as always …