Socket Destination Port Problem

This is a discussion on Socket Destination Port Problem within the Networking/Device Communication forums, part of the General Programming Boards category; Hi everybody,
I have an application where two different socket connections run in order to communicate with a machine. Over ...

Socket Destination Port Problem

Hi everybody,

I have an application where two different socket connections run in order to communicate with a machine. Over the first one (UDP) I send a request packet to ask for data and over the other one connection (TCP) I receive the data.
I repeat this procedure two times that is, I request a block of data and when it's finished I request a second one.By the first time it works without problems but by the second time I discovered with wireshark that the request packet is sent to another port (not over the original port). I know I haven't made changes between the first request call and the second one because I have a function where I initialize all connections at the beginning and it works for the first transmission.

I have a tcp server that wait for data in the recv function after accept. I receive data buffer of 1500 bytes but I don't receive only one buffer. I receive more. The first time the socket receives something port=2000 (so it's right) but the second time and successively port=49154. Something is wrong with the receive function...