UDP is connectionless so you can retrieve the address of the incoming stream from first bytes of the same.
With TCP in order to communicate you have to have established a connection.
The following is an example of TCP server do in basic metalanguage that go in the continuous loop of your main program …
If Socket(sockreg, cSn_MR_TCP, TCP_PORT, 0) Then
If Not Listen(sockreg) Then
rsize = W5500.DataAvailable(sockreg)
If rsize > 0 Then
' Here someone has connected and there is a flow of data.
' You can read here Sn_DIPR0..Sn_DIPR3 for IP address and Sn_DHAR0 .. Sn_DHAR5 for MAC.
' However you can read the receive buffer and create the answer in the transmit buffer
' without having to know the address of the caller.
' If you need to communicate in HTTP remember to disconnect the socket
' just concluded the transmission otherwise receiving will go in timeout.
' here has disconnected then close the socket
When the connection is established in fact you do not need anything else unless you intend to open a second socket to those who contacted you earlier in the socket. However you can know the remote address via the 4 registers ( socket offset registers ) Sn_DIPR0…Sn_DIPR3 for the IP address and via Sn_DHAR0 … Sn_DHAR5 its MAC address.
In the C++ sources as provided in W5500 support site are routines that do this.