All pastes #945518 Raw Edit

Untitled

public text v1 · immutable
·published 2008-03-16 23:56 UTC
rendered paste body
#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 = "Hi";
int som;
 if ((send = net_send(&som, &data, sizeof(data))) != 0) {
  printf("Cannot send data");
  printf(send);
  goto exit;
 }
net_close(connection);
exit:
 return 0;
}




#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 = "Hi";
int som;

if (recv = net_recv(&som, &data, sizeof(data)) != 0) {
  printf("Unable to receive data.");
  printf(recv);
  goto exit;
}

exit:
 return 0;
}