DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ L T ┃
Length: 5837 (0x16cd) Types: TextFile Names: »LE_C«
└─⟦149519bd4⟧ Bits:30000546 8mm tape, Rational 1000, !projects 93-07-13 └─ ⟦124ff5788⟧ »DATA« └─⟦this⟧ └─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11 └─ ⟦129cab021⟧ »DATA« └─⟦this⟧ └─⟦f64eaa120⟧ Bits:30000752 8mm tape, Rational 1000, !projects 93 02 16 └─ ⟦6f12a12be⟧ »DATA« └─⟦this⟧ └─⟦2f6cfab89⟧ Bits:30000547 8mm tape, Rational 1000, !projects 94-01-04 └─ ⟦d65440be7⟧ »DATA« └─⟦this⟧
#include <sys/types.h> #include <sys/socket.h> #include <netinet/in.h> #include <netdb.h> #include <fcntl.h> #include <sys/ioctl.h> #include "Defs.h" static int Blocking_Mode = 0; void Close_Socket(socket_id) int socket_id; { close(socket_id); shutdown(socket_id, 2); } void Create_Socket(port, type, new_socket) int *port,type, *new_socket; { int socket_id; struct sockaddr_in socket_address; int socket_address_length; socket_id = socket(AF_INET,type,0); if (socket_id == -1) { perror("(Couche_Basse_Msg.c).Create_Socket : Create socket error"); exit(-1); } bzero((char *) &socket_address ,sizeof(socket_address)); socket_address.sin_port = *port; socket_address.sin_addr.s_addr = INADDR_ANY; socket_address.sin_family = AF_INET; if (bind(socket_id, &socket_address, sizeof(socket_address))) { perror("(Couche_Basse_Msg.c).Create_Socket : Bind socket error"); exit(-1); } socket_address_length = sizeof(socket_address); if (getsockname(socket_id, &socket_address, &socket_address_length)) { perror("(Couche_Basse_Msg.c).Create_Socket : Getsockname error"); exit(-1); } *port = ntohs(socket_address. sin_port); *new_socket = socket_id; } int Create_Server(port_number) int port_number; /* In fact, listen port number */ { int listen_socket_id; Create_Socket(&port_number, SOCK_STREAM, &listen_socket_id); if(listen_socket_id == -1) { perror("(Couche_Basse_Msg.c).Create_Server : Listen socket create error"); exit (-1); } /* Start accepting connection */ if(listen(listen_socket_id, NB_MAX_PENDING_CONNECTIONS) == -1) { perror("(Couche_Basse_Msg.c).Create_Server : Make Listen socket listening error"); exit (-1); } return (listen_socket_id); } int Server_Wait_For_A_Connection (listen_socket_id) int listen_socket_id; { int service_socket_id; struct sockaddr_in address_client_socket; int lg_address_client_socket; char error_message[150]; lg_address_client_socket = sizeof(address_client_socket); service_socket_id = accept(listen_socket_id, &address_client_socket, &lg_address_client_socket); if (service_socket_id == -1) { sprintf(error_message, "(Couche_Basse_Msg.c).Server_Wait_For_A_Connection : accept error (listen_socket_id = %d", listen_socket_id); perror(error_message); exit (-1); } return (service_socket_id); } int Join_Server(server_name, length_of_server_name, port_number) char *server_name; int length_of_server_name; int port_number; { int socket_id; struct hostent *hp; /* pour le gethostbyname */ struct sockaddr_in server_socket_address; socket_id = socket (AF_INET, SOCK_STREAM, 0); if (socket_id == -1 ) { perror ("(Couche_Basse_Msg.c).Join_Server : Create socket error"); exit (-1); } server_socket_address.sin_family = AF_INET; server_socket_address.sin_port = htons(port_number); server_name[length_of_server_name] = 0; if (!(hp=gethostbyname(server_name))) { perror ("(Couche_Basse_Msg.c).Join_Server : gethostbyname error"); printf("Server : %s\n", server_name); exit (-1); } bcopy(hp->h_addr, &server_socket_address.sin_addr, hp->h_length); if (connect(socket_id, &server_socket_address, sizeof(server_socket_address)), 0) { perror("(Couche_Basse_Msg.c).Join_Server : connecting stream socket error"); exit(1); } return (socket_id); } void Make_Non_Blocking (socket_id) int socket_id; { int val_bidon_for_ioctl = 1; ioctl(socket_id, FIONBIO, &val_bidon_for_ioctl); Blocking_Mode = 0; } void Make_Blocking_For_Close(socket_id) int socket_id; { struct linger lng; lng.l_linger = 1; lng.l_onoff = 1; setsockopt(socket_id, SOL_SOCKET, SO_LINGER, &lng, sizeof(lng)); Blocking_Mode = 1; } void Send_String(remote_socket_id, buffer_to_send, length_of_buffer_to_send, number_of_caracteres_sent) int remote_socket_id; char buffer_to_send[]; int length_of_buffer_to_send; int * number_of_caracteres_sent; { *number_of_caracteres_sent = write(remote_socket_id, buffer_to_send, length_of_buffer_to_send); } void Receive_String(remote_socket_id, buffer_to_receive, length_of_buffer_to_receive, number_of_caracteres_received) int remote_socket_id; char *buffer_to_receive; int length_of_buffer_to_receive; int *number_of_caracteres_received; { int length_current_read = 0; char current_read_buffer[BUFF_SIZE]; int total_length_read = 0; int total_free_space = length_of_buffer_to_receive; strcpy(buffer_to_receive, ""); while(1) { length_current_read = read(remote_socket_id, buffer_to_receive, length_of_buffer_to_receive); if(length_current_read > 0) { *number_of_caracteres_received = length_current_read; break; } if (!Blocking_Mode) break; } }