Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sys/socket.h>
- #include <netinet/in.h>
- #include <stdio.h>
- #include <strings.h>
- int main(int argc, char** argv) {
- struct sockaddr_in6 server;
- char buf[20];
- int no, asd, sd = socket(AF_INET6, SOCK_STREAM, 0);
- bzero(&server, sizeof(server));
- server.sin6_family = AF_INET6;
- server.sin6_addr = in6addr_any;
- server.sin6_port = 4242;
- bind(sd, (struct sockaddr*) &server, sizeof(server));
- listen(sd, 5);
- while (1) {
- printf("Waiting for connection....\n");
- asd = accept(sd, 0, 0);/* Block until complete connect */
- if ((no = read(asd, buf, sizeof(buf))) != -1)
- printf("Recieved %d bytes: %s\n", no, buf);
- close(asd);
- }
- close(sd);
- }
Add Comment
Please, Sign In to add comment