Bind a socket

Michalis Kabrianis kabrianis at hellug.gr
Thu May 4 10:56:50 EEST 2000


Geia sas.
Sygnwmmi alla aisthanomai ligo xazos, kai fobamai oti exw kollisei.
Mipws mporei kapoios na mou pei ti den paei kala sto katwthi programma kai mou
bgazei error:

bind: Socket operation on non-socket

-----cut here------
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#define PORT 9765

int sock, bound;
struct sockaddr_in insock;

main() {
bzero(&insock, sizeof(insock));
insock.sin_port=htons(PORT);
insock.sin_family=AF_INET;
insock.sin_addr.s_addr=INADDR_ANY;
if (sock=socket(AF_INET, SOCK_STREAM, 0) < 0 ) {
        perror("socket");
        exit(1);
}
if (bound=bind(sock, (struct sockaddr *) &insock, sizeof(insock)) < 0 ) {
        perror("bind");
        exit(2);
}
}

Eyxaristw ek twn proterwn.


Michalis Kabrianis
kabrianis at hellug.gr
http://homepages.pathfinder.gr/mkab

--
linux-greek-users mailing list -- http://lists.hellug.gr




More information about the Linux-greek-users mailing list