Functions | Variables

nse_client.c File Reference

#include <string.h>
#include "echo.h"
#include "proxylib.h"
Include dependency graph for nse_client.c:

Go to the source code of this file.

Functions

void str_cli (FILE *, int)
int main (int argc, char **argv)

Variables

int ns_errno

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 10 of file nse_client.c.

{
  int sockfd;
  PROXY_COMPONENTADDR servaddr;

  if (argc != 3) {
    fprintf(stderr, "usage: tcpcli <server component ID> <port>\n");
    exit(EXIT_FAILURE);
  }

  proxy_init("nse.cfg");

  proxy_str_to_cid(servaddr.ID, argv[1]);

  servaddr.port = htons(atoi(argv[2]));
  servaddr.IP = 0;
  servaddr.proxyIP = proxy_get_proxy_ip();
  servaddr.proxyPort = proxy_get_proxy_port();

  sockfd = proxy_socket(AF_INET, SOCK_STREAM, 0);

  if (proxy_connect(sockfd, &servaddr) < 0) {
    fprintf(stderr, "Error: could not connect.\n");
    exit(EXIT_FAILURE);
  }

  str_cli(stdin, sockfd);   /* do it all */

  exit(EXIT_SUCCESS);
}

Here is the call graph for this function:

void str_cli ( FILE *  fp,
int  sockfd 
)

Definition at line 41 of file nse_client.c.

{
  char sendline[MAXLINE], recvline[MAXLINE];

  while (fgets(sendline, MAXLINE, fp) != NULL) {

    Writen(sockfd, sendline, strlen(sendline));

    if (Readline(sockfd, recvline, MAXLINE) == 0) {
      fprintf(stderr, "str_cli: server terminated prematurely");
      return;
    }

    fputs(recvline, stdout);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

int ns_errno

Definition at line 6 of file nse_client.c.