Jump to content

sendto() doesn't work after the first time I call it


Guest ECB

Recommended Posts

Topic has the description. I'm using a nonblocking UDP socket. This is weird, and I have no idea where to look for the problem.

 

I've counted the amount returned by all those sendto() calls and it matches the amount that i've been sending. This means that all my sendto()s where successful...right?

 

Could the problem with the program I'm using to receive the data being sent? I have no idea how to check it though.

Edited by ECB
Link to comment
Share on other sites

And some code:

int sock;

struct sockaddr_in sain;

sock=socket(AF_INET,SOCK_DGRAM,0);

sain.sin_family=AF_INET;

sain.sin_port=htons(8888);

sain.sin_addr.s_addr=INADDR_ANY;

bind(sock,(struct sockaddr *) &sain,sizeof(sain));

int tempI=1;

ioctl(sock,FIONBIO,&tempI);

 

sain.sin_family=AF_INET;

sain.sin_port=htons(8888);

sain.sin_addr.s_addr=inet_addr("192.168.0.105");

 

char lolChar1 = 50;

char lolChar2 = 51;

 

sendto(sock, &lolChar1, sizeof(lolChar1),0,(struct sockaddr *)&sain,sizeof(sain));

sendto(sock, &lolChar2, sizeof(lolChar2),0,(struct sockaddr *)&sain,sizeof(sain));

 

For some reason, I receive a 50 but not a 51 on the other end. In the wifi_lib_test, I went to the UDP test and added another sendto() right beside the original call. It works, I receive two values instead of one. What am I missing here?

Edited by ECB
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...