Socket « integer « C Data Type Q&A

Home
C Data Type Q&A
1.binary
2.bit
3.byte
4.char
5.character
6.decimal
7.Development
8.float
9.hex
10.integer
11.prime
12.random
13.struct
C Data Type Q&A » integer » Socket 

1. Sending an int over TCP (C-programming)    stackoverflow.com

I have a server and a client program (both running on the same machine). The client is able to send a struct to the server with members such as "ID", "size" ...

2. How to send an integer through a socket?    stackoverflow.com

I am trying to send an integer through a socket. I am using this code to do so; however, my C code will not compile. The compiler complains that myInt has ...

3. How does accept( ) determine which integer to return?    stackoverflow.com

Using the C sockets library on a Linux system... When I make a call to accept( ) it always returns an integer. STDIN is 0. Usually my first accept call ...

4. read integer through a socket c    stackoverflow.com

i need to read an integer through a socket and the sens it to a function. i do

strcpy(out,"insert id messagge\n");
if (write(sd_client,out, sizeof(out))==-1){
    printf("Error.\n");
    }
while ...

5. Send signed ints to/from socket    stackoverflow.com

Writing an application which sends 4 ints over socket, trying the following but getting 0s at receiving end... I assume this is something to do with the way I'm passing them signedness ...

6. Need help with sending an int via sockets.    cboard.cprogramming.com

7. Send and Int Through Socket?    cboard.cprogramming.com

8. Reading integer from socket    forums.devshed.com

#include #include #include #include #include #include int main(int argc,char *argv[]) { int c,s,num; socklen_t l; struct sockaddr_in cli,serv; serv.sin_family=AF_INET; serv.sin_port=htons(2000); serv.sin_addr.s_addr=INADDR_ANY; if((s=socket(AF_INET,SOCK_STREAM,0))<0) { perror("socket"); return -1; } if(bind(s,(struct sockaddr *)&serv,sizeof(struct sockaddr))<0) { perror("bind"); return -1; } if(listen(s,5)<0) { perror("listen"); return -1; } for(;;) { c=accept(s,(struct sockaddr *)&cli,&l); recv(c,&num,sizeof(int),0); fprintf(stdout,"num=%d",ntohl(num)); close(c); } return 0; }

java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.