All pastes #945546 Raw Edit

Mine

public text v1 · immutable
·published 2008-03-17 00:30 UTC
rendered paste body
client.c:

#include <stdio.h>
#include <xyssl/net.c>

int main() {
 int fd, connection, send;
 char *host = "localhost";
 int port = 3000;
 if ((connection = net_connect(&fd, host, port)) != 0) {
  printf("Connection unavailable.");
  goto exit;
 }

char *data = "hhi";
 if ((send = net_send(&fd, data, sizeof(data))) <= 0) {
  printf("Cannot send data");
  goto exit;
 }

exit:
net_close(connection);

 return 0;
}

server.c:

#include <stdio.h>
#include <xyssl/net.c>

int main() {
 int fd, bind, accept, recv;
 char *host = "localhost";
 int port = 3000;
 if ((bind = net_bind(&fd, host, port)) != 0) {
  printf("Unable to bind.");
  goto exit;
 }

int client_fd = -1;

if (accept = net_accept(fd, &client_fd, NULL) != 0) {
 printf("Unable to accept data.");
 goto exit;
}
char *data;
if (recv = net_recv(&fd, data, sizeof(data)) <= 0) {
  printf("Unable to receive data: ");
  printf("%c\n", &data);
  goto exit;
}

exit:
 return 0;
}