[BACK]Return to mysocket.c CVS log [TXT][DIR] Up to [local] / OpenXM / src / ox_toolkit

Diff for /OpenXM/src/ox_toolkit/mysocket.c between version 1.6 and 1.7

version 1.6, 2000/12/01 16:31:11 version 1.7, 2003/01/11 11:42:31
Line 1 
Line 1 
 /* -*- mode: C; coding: euc-japan -*- */  /* -*- mode: C; coding: euc-japan -*- */
 /* $OpenXM: OpenXM/src/ox_toolkit/mysocket.c,v 1.5 2000/11/30 16:07:35 ohara Exp $ */  /* $OpenXM: OpenXM/src/ox_toolkit/mysocket.c,v 1.6 2000/12/01 16:31:11 ohara Exp $ */
 /*  /*
 Q: How to get a local port number?  Q: How to get a local port number?
 A: You do setsockopt() to set options and do socket(), bind().  A: You do setsockopt() to set options and do socket(), bind().
Line 27  Reference
Line 27  Reference
 #endif  #endif
   
 #include "mysocket.h"  #include "mysocket.h"
   #include "ox_toolkit.h"
   
 typedef struct ox_sockopt {  typedef struct ox_sockopt {
     int       level;      int       level;
Line 52  static int ox_connect(char *hostname, int port, ox_soc
Line 53  static int ox_connect(char *hostname, int port, ox_soc
     struct sockaddr_in serv;      struct sockaddr_in serv;
     int s = getsocket(&serv, hostname, port);      int s = getsocket(&serv, hostname, port);
     if (connect(s, (struct sockaddr *)&serv, sizeof(serv)) != 0) {      if (connect(s, (struct sockaddr *)&serv, sizeof(serv)) != 0) {
         fprintf(stderr, "ox_connect: failed. socket = %d, errno = %d\n", s, errno);          fprintf(ox_stderr, "ox_connect: failed. socket = %d, errno = %d\n", s, errno);
         return -1;          return -1;
     }      }
     return s;      return s;
Line 67  static int ox_listen(char *hostname, int *port, int ba
Line 68  static int ox_listen(char *hostname, int *port, int ba
                opt->option_value, opt->option_len);                 opt->option_value, opt->option_len);
     if (bind(s_waiting, (struct sockaddr *)&me, sizeof(me)) < 0      if (bind(s_waiting, (struct sockaddr *)&me, sizeof(me)) < 0
         || listen(s_waiting, backlog) < 0) {          || listen(s_waiting, backlog) < 0) {
         fprintf(stderr, "ox_listen: failed.\n");          fprintf(ox_stderr, "ox_listen: failed.\n");
         return -1;          return -1;
     }      }
     return s_waiting;      return s_waiting;
Line 78  static int ox_getport(int s_waiting)
Line 79  static int ox_getport(int s_waiting)
     struct sockaddr_in me;      struct sockaddr_in me;
     int len = sizeof(me);      int len = sizeof(me);
     if (getsockname(s_waiting, (struct sockaddr *)&me, &len) < 0) {      if (getsockname(s_waiting, (struct sockaddr *)&me, &len) < 0) {
         fprintf(stderr, "ox_getport: failed.\n");          fprintf(ox_stderr, "ox_getport: failed.\n");
         return -1;          return -1;
     }      }
     return ntohs(me.sin_port);      return ntohs(me.sin_port);
Line 112  int mypipe(char *program, int fd1, int fd2)
Line 113  int mypipe(char *program, int fd1, int fd2)
 {  {
     int sockfd[2];      int sockfd[2];
     if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockfd) < 0) {      if (socketpair(AF_UNIX, SOCK_STREAM, 0, sockfd) < 0) {
         fprintf(stderr, "socketpair: fail! errno = %d\n", errno);          fprintf(ox_stderr, "socketpair: fail! errno = %d\n", errno);
     }      }
     if (fork() == 0) {      if (fork() == 0) {
         /* child process */          /* child process */

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>