Página principal | Jerarquía de la clase | Lista alfabética | Lista de componentes | Lista de archivos | Miembros de las clases | Archivos de los miembros | Páginas relacionadas

jed_tcp.h

Ir a la documentación de este archivo.
00001 //===========================================================================
00002 //= jed_udp.h                                             Noviembre de 1998 =
00003 //=-------------------------------------------------------------------------=
00004 //= Definiciones portables para el uso de sockets en modo TCP.              =
00005 //=-------------------------------------------------------------------------=
00006 //= ADVERTENCIA: ESTE SOFTWARE NO ESTA CONCEBIDO NI DISENNADO PARA EL USO   =
00007 //= EN EQUIPO DE CONTROL EN LINEA EN ENTORNOS PELIGROSOS QUE REQUIERAN UN   =
00008 //= DESEMPENNO LIBRE DE FALLAS, COMO LA OPERACION DE PLANTAS NUCLEARES,     = 
00009 //= SISTEMAS DE NAVEGACION O COMUNICACION EN AVIONES, TRAFICO AEREO,        =
00010 //= EQUIPO MEDICO DEL CUAL DEPENDAN VIDAS HUMANAS O SISTEMAS DE ARMAMENTO,  =
00011 //= EN LOS CUALES UNA FALLA EN EL SOFTWARE PUEDA IMPLICAR DIRECTAMENTE LA   =
00012 //= MUERTE, DANNOS PERSONALES O DANNOS FISICOS Y/O AMBIENTALES GRAVES       =
00013 //= ("ACTIVIDADES DE ALGO RIESGO").                                         =
00014 //=-------------------------------------------------------------------------=
00015 //= Autor original: Oscar J. Chavarro G.  A.K.A. JEDILINK. Copyright (c),   =
00016 //= 1997 - 2003, oscarchavarro@hotmail.com                                  =
00017 //= AQUYNZA es software libre, y se rige bajo los terminos de la licencia   =
00018 //= LGPL de GNU (http://www.gnu.org). Para mayor informacion respecto a la  =
00019 //= licencia de uso, consulte el archivo ./doc/LICENCIA en la distribucion. =
00020 //===========================================================================
00021 
00022 #ifndef __JED_TCP__
00023 #define __JED_TCP__
00024 
00025 #include "jed_defs.h"
00026 
00027 #ifdef UNIX_ENABLED
00028     #include <errno.h>
00029     #include <unistd.h>
00030   #ifdef SOCKETS_ENABLED
00031     #include <arpa/inet.h>
00032     #include <netinet/in.h>
00033     #include <sys/types.h>
00034     #include <sys/socket.h>
00035     #include <sys/stat.h>
00036 
00037     #include "toolkits/media/_unix_io.h"
00038 
00039     #define LPSOCKADDR struct sockaddr *  // OJO: No es mejor un typedef?
00040   #endif // SOCKETS_ENABLED
00041 #endif
00042 
00043 #ifdef SOCKETS_ENABLED
00044 #if PLATAFORMA == i386_WIN32_VC
00045     #include <winsock.h>
00046 #endif
00047 #endif // SOCKETS_ENABLED
00048 
00049 class CONEXION_TCP {
00050   private:
00051     int _id;
00052     char *Nombre_servidor;
00053     int puerto_servidor;
00054 #ifdef UNIX_ENABLED
00055     int sockfd;
00056     BOOLEAN _pendiente;
00057 #endif
00058 #if PLATAFORMA == i386_WIN32_VC
00059     SOCKET sockfd;
00060 #endif
00061 
00062 #ifdef SOCKETS_ENABLED
00063     struct sockaddr_in direccion_servidor;
00064     struct sockaddr_in direccion_cliente;
00065 #endif
00066 
00067     CONEXION_TCP();
00068   public:
00069     CONEXION_TCP(char *nombre, int puerto);
00070     ~CONEXION_TCP();
00071 
00072     int id(void);
00073     BOOLEAN pendiente(void);
00074     void set_id(int i);
00075     void cerrar(void);
00076     void origen(DWORD *ip, WORD *puerto);
00077     BOOLEAN crear_como_servidor(void);
00078     BOOLEAN crear_como_cliente(void);
00079     int enviar(char *buffer, int tam_buffer);
00080     int recibir(char *buffer, int tam_buffer);
00081     CONEXION_TCP *aceptar_conexion(void);
00082     void registro_asincronico(void (*f)(void *, int), void *User_data);
00083 
00084 };
00085 
00086 inline void
00087 CONEXION_TCP::origen(DWORD *ip, WORD *puerto)
00088 {
00089 #ifdef SOCKETS_ENABLED
00090     (*ip) = direccion_cliente.sin_addr.s_addr;
00091     (*puerto) = direccion_cliente.sin_port;
00092 #endif
00093 }
00094 
00095 #endif // __JED_TCP__
00096 
00097 //===========================================================================
00098 //= EOF                                                                     =
00099 //===========================================================================
00100 

Este archivo HTML ha sido generado automáticamente a partir del código fuente AQUYNZA. NO LO EDITE. Para mayor información contacte al autor.