Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <netinet/in.h>
- #include <sys/socket.h>
- #include <arpa/inet.h>
- #include <string.h>
- #include <sys/types.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <unistd.h>
- #define PORT 10000
- #define LOOPB "127.0.0.1" //"10.16.4.135"
- #define MAXLEN 99
- int main()
- {
- char mesaj[100];
- int len;
- struct sockaddr_in loopback;
- int sock = socket(PF_INET, SOCK_STREAM, 0);
- // Stetez sockaddr
- loopback.sin_family = AF_INET;
- loopback.sin_port = htons(PORT);
- inet_aton(LOOPB, &(loopback.sin_addr));
- // Fac bind
- //bind(sock, (void *)&loopback, sizeof(struct sockaddr_in));
- // Connect
- connect(sock, (struct sockaddr *)&loopback, sizeof(struct sockaddr_in));
- gets(mesaj);
- // send(sock, mesaj, strlen(mesaj), 0);
- while (send(sock, mesaj, strlen(mesaj) + 1, 0) != -1) {
- recv(sock, mesaj, MAXLEN, 0);
- printf("am primit : %s\n", mesaj);
- gets(mesaj);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment