can any one tell me why the following code always return 0 . the socket descriptor value is 3.
i am using the open suse TFTP server . which is listening on port 69 in Local host.
connect() function return success ..
connection_timer.tv_sec = 2; // s
connection_timer.tv_usec = 0;
FD_ZERO(&fd_reader);
// laukiam, kol bus ka nuskaityti
FD_SET(socket_descriptor, &fd_reader);
int select_ready = select(socket_descriptor + 1, &fd_reader, NULL, NULL, &connection_timer);
When i use TCPdump to check the packet it send the first packet then the connection is closed in somewhere before receive Ack received..
I suspect that you are not receiving the response because you used
connect()on a UDP socket, which made it so that you only accept datagrams from the connected destination.Since the TFTP reply does not come from port 69, but rather from an ephemeral port, the acknowledgement is never received.
Solution: Don’t
connect()your UDP socket until after you finish the initial connection.