home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
-
- void send(socket, string)
- int socket;
- char *string;
- {
- int length = strlen(string) + 1;
- if (write(socket, string, length) != length) {
- fprintf(stderr, "Write failed on socket %d\n", socket);
- fprintf(stderr, "String was \"%s\"\n", string);
- abort();
- }
- }
-
- void receive(socket, string)
- int socket;
- char *string;
- {
- int length;
- length = read(socket, string, 4096);
- if (length < 0) {
- perror("receive: (read)");
- abort();
- } else if (length == 0) {
- *string = '\0';
- }
- }
-