By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,804 Members | 1,627 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,804 IT Pros & Developers. It's quick & easy.

Error in my code somewhere, i think ?

P: 11
hi all,

ok this is what i am trying to do. log on and authenticate. i have written the code below which asks for a serial number, which then gets passed over to the server. for the moment i am just printing the number, which gives me the code

SOCKET INFO: accept left errorno 25 and new socket 4.

however before this code appeared the numbers did not match.

anyone got any tips on whats going on here?

oh and be kind to me and keep it simple please !




server

/* get user id from client */
recv_data(sock,box);
sprintf("your settopbox number is %ld\n",box);
close_socket(sock);

client

printf("Please enter your SetTopBox Number\t");
scanf("%s",box);
printf("Please enter your Customer ID\t");
scanf("%s",id);
send_data(local_socket,box,strlen(box)+1);
send_data(local_socket,id,strlen(id)+1);
Mar 23 '07 #1
Share this Question
Share on Google+
5 Replies


DeMan
100+
P: 1,806
Could you please clarify where the numbers do not match (and how you know that they don't) - and please use code tags if posting code (use the word code to start and /code to finish both inside [ ])
Mar 23 '07 #2

P: 11
hi the number that i put into the client for the settopbox, does not match the settopbox number printed on the server program.

i am hoping that the code listed below asks me for my settopbox number, which i store and then send to the server, the same applies for the customer id.

i then have the sprintf in the server to display the settopbox number.

Expand|Select|Wrap|Line Numbers
  1.  
  2. server
  3.  
  4. /* get user id from client */
  5. recv_data(sock,box);
  6. sprintf("your settopbox number is %ld\n",box);
  7. close_socket(sock);
  8.  
  9. client
  10.  
  11. printf("Please enter your SetTopBox Number\t");
  12. scanf("%s",box);
  13. printf("Please enter your Customer ID\t");
  14. scanf("%s",id);
  15. send_data(local_socket,box,strlen(box)+1);
  16. send_data(local_socket,id,strlen(id)+1);
  17.  
  18.  
Mar 23 '07 #3

DeMan
100+
P: 1,806
I think the problem may be that you get the Set top box number as a string (array of characters) rather than a number (try scanf("%d\n" box)).
The characters "1234" are represtented different to the number 1234 internally.
I'm also not sure why you add one to the lengths you are sending....
Mar 23 '07 #4

P: 11
ok well i tried that and it got rid of my error code ....

however if i type in the settopbox number as 123456789 it equals 536850328 and if i type in the customer id as 1234 it comes out as 536850344.

can you tell me why these numbers are misrepresented ?
Mar 23 '07 #5

DeMan
100+
P: 1,806
I suspect you may need to take a reference from recv_data (that is &box), and possibly pass it that way to send also (I think the numbers you are geeting are memory references)
Mar 23 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.