[BACK]Return to sio.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib2 / asir2000 / io

Diff for /OpenXM_contrib2/asir2000/io/sio.c between version 1.11 and 1.12

version 1.11, 2000/12/05 01:24:55 version 1.12, 2001/10/09 01:36:21
Line 44 
Line 44 
  * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY   * OF THE SOFTWARE HAS BEEN DEVELOPED BY A THIRD PARTY, THE THIRD PARTY
  * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,   * DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE,
  * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.   * PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE.
  * $OpenXM: OpenXM_contrib2/asir2000/io/sio.c,v 1.10 2000/11/15 01:20:27 noro Exp $   * $OpenXM: OpenXM_contrib2/asir2000/io/sio.c,v 1.11 2000/12/05 01:24:55 noro Exp $
 */  */
 #include "ca.h"  #include "ca.h"
 #include "setjmp.h"  #include "setjmp.h"
 #include "ox.h"  #include "ox.h"
 #if defined(VISUAL)  #if defined(VISUAL)
 #include <winsock2.h>  #include <winsock2.h>
   #include <io.h>
 #else  #else
 #include <sys/time.h>  #include <sys/time.h>
 #include <sys/uio.h>  #include <sys/uio.h>
Line 75  struct IOFP iofp[MAXIOFP];
Line 76  struct IOFP iofp[MAXIOFP];
   
 void init_socket(void);  void init_socket(void);
   
 int getremotesocket(s)  int getremotesocket(int s)
 int s;  
 {  {
         return iofp[s].s;          return iofp[s].s;
 }  }
   
 void getremotename(s,name)  void getremotename(int s,char *name)
 int s;  
 char *name;  
 {  {
         struct sockaddr_in peer;          struct sockaddr_in peer;
         struct hostent *hp;          struct hostent *hp;
Line 98  char *name;
Line 96  char *name;
                 strcpy(name,(char *)inet_ntoa(peer.sin_addr));                  strcpy(name,(char *)inet_ntoa(peer.sin_addr));
 }  }
   
 int generate_port(use_unix,port_str)  void generate_port(int use_unix,char *port_str)
 int use_unix;  
 char *port_str;  
 {  {
         double get_current_time();          double get_current_time();
         unsigned long mt_genrand();          unsigned long mt_genrand();
Line 121  char *port_str;
Line 117  char *port_str;
         }          }
 }  }
   
 int try_bind_listen(use_unix,port_str)  int try_bind_listen(int use_unix,char *port_str)
 int use_unix;  
 char *port_str;  
 {  {
         struct sockaddr_in sin;          struct sockaddr_in sin;
         struct sockaddr *saddr;          struct sockaddr *saddr;
Line 156  char *port_str;
Line 150  char *port_str;
                         return -1;                          return -1;
                 }                  }
                 sin.sin_family = AF_INET; sin.sin_addr.s_addr = INADDR_ANY;                  sin.sin_family = AF_INET; sin.sin_addr.s_addr = INADDR_ANY;
                 sin.sin_port = htons(atoi(port_str));                  sin.sin_port = htons((unsigned short)atoi(port_str));
                 len = sizeof(sin);                  len = sizeof(sin);
                 saddr = (struct sockaddr *)&sin;                  saddr = (struct sockaddr *)&sin;
         }          }
Line 192  char *port_str;
Line 186  char *port_str;
   the original socket is always closed.    the original socket is always closed.
 */  */
   
 int try_accept(af_unix,s)  int try_accept(int af_unix,int s)
 int af_unix,s;  
 {  {
         int len,c,i;          int len,c,i;
         struct sockaddr_in sin;          struct sockaddr_in sin;
Line 218  int af_unix,s;
Line 211  int af_unix,s;
         return c;          return c;
 }  }
   
 int try_connect(use_unix,host,port_str)  int try_connect(int use_unix,char *host,char *port_str)
 int use_unix;  
 char *host,*port_str;  
 {  {
         struct sockaddr_in sin;          struct sockaddr_in sin;
         struct sockaddr *saddr;          struct sockaddr *saddr;
Line 255  char *host,*port_str;
Line 246  char *host,*port_str;
                                 return -1;                                  return -1;
                         }                          }
                         bzero(&sin,sizeof(sin));                          bzero(&sin,sizeof(sin));
                         sin.sin_port = htons(atoi(port_str));                          sin.sin_port = htons((unsigned short)atoi(port_str));
                         sin.sin_addr.s_addr = inet_addr(host);                          sin.sin_addr.s_addr = inet_addr(host);
                         if ( sin.sin_addr.s_addr != -1 ) {                          if ( sin.sin_addr.s_addr != -1 ) {
                                 sin.sin_family = AF_INET;                                  sin.sin_family = AF_INET;
Line 286  char *host,*port_str;
Line 277  char *host,*port_str;
 }  }
   
 #if 0  #if 0
 close_allconnections()  void close_allconnections()
 {  {
         int s;          int s;
   
Line 297  close_allconnections()
Line 288  close_allconnections()
                 close_connection(s);                  close_connection(s);
 }  }
   
 close_connection(s)  void close_connection(int s)
 int s;  
 {  {
         struct IOFP *r;          struct IOFP *r;
   
Line 310  int s;
Line 300  int s;
         }          }
 }  }
 #else  #else
 close_allconnections()  void close_allconnections()
 {  {
         shutdown_all();          shutdown_all();
 }  }
 #endif  #endif
   
 free_iofp(s)  void free_iofp(int s)
 int s;  
 {  {
         struct IOFP *r;          struct IOFP *r;
   
Line 331  int s;
Line 320  int s;
   
 #define LBUFSIZ BUFSIZ*10  #define LBUFSIZ BUFSIZ*10
   
 int get_iofp(s1,af_sock,is_server)  int get_iofp(int s1,char *af_sock,int is_server)
 int s1;  
 char *af_sock;  
 int is_server;  
 {  {
         int i;          int i;
         unsigned char c,rc;          unsigned char c,rc;
Line 373  int is_server;
Line 359  int is_server;
                 c = 0xff;                  c = 0xff;
         if ( is_server ) {          if ( is_server ) {
                 /* server : write -> read */                  /* server : write -> read */
                 write_char(iofp[i].out,&c); ox_flush_stream_force(i);                  write_char((FILE *)iofp[i].out,&c); ox_flush_stream_force(i);
                 read_char(iofp[i].in,&rc);                  read_char((FILE *)iofp[i].in,&rc);
         } else {          } else {
                 /* client : read -> write */                  /* client : read -> write */
                 read_char(iofp[i].in,&rc);                  read_char((FILE *)iofp[i].in,&rc);
                 /* special care for a failure of spawing a server */                  /* special care for a failure of spawing a server */
                 if ( rc !=0 && rc != 1 && rc != 0xff )                  if ( rc !=0 && rc != 1 && rc != 0xff )
                         return -1;                          return -1;
                 write_char(iofp[i].out,&c); ox_flush_stream_force(i);                  write_char((FILE *)iofp[i].out,&c); ox_flush_stream_force(i);
         }          }
         iofp[i].conv = c == rc ? 0 : 1;          iofp[i].conv = c == rc ? 0 : 1;
         if ( af_sock && af_sock[0] ) {          if ( af_sock && af_sock[0] ) {
Line 410  void init_socket()
Line 396  void init_socket()
 }  }
 #endif  #endif
   
 get_fd(index)  int get_fd(int index)
 int index;  
 {  {
         return iofp[index].s;          return iofp[index].s;
 }  }
   
 get_index(fd)  int get_index(int fd)
 int fd;  
 {  {
         int i;          int i;
   

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12

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