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_udp.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 UDP.              =
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_UDP__
00023 #define __JED_UDP__
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     #define LPSOCKADDR struct sockaddr *  // OJO: No es mejor un typedef?
00038   #endif // SOCKETS_ENABLED
00039 #endif
00040 
00041 #ifdef SOCKETS_ENABLED
00042 #if PLATAFORMA == i386_WIN32_VC
00043     #include <winsock.h>
00044 #endif
00045 #endif // SOCKETS_ENABLED
00046 
00047 class CONEXION_UDP {
00048   private:
00049     int _id;
00050     char *Nombre_servidor;
00051     int puerto_servidor;
00052 #ifdef UNIX_ENABLED
00053     int sockfd;
00054 #endif
00055 #if PLATAFORMA == i386_WIN32_VC
00056     SOCKET sockfd;
00057 #endif
00058 #ifdef SOCKETS_ENABLED
00059     struct sockaddr_in extremo_remoto;
00060 #endif
00061 
00062   public:
00063     CONEXION_UDP(char *nombre, int puerto);
00064     ~CONEXION_UDP();
00065 
00066     int id(void);
00067     void origen(DWORD *ip, WORD *puerto);
00068     void set_origen(DWORD ip, WORD puerto);
00069     void set_id(int i);
00070     void cerrar(void);
00071     BOOLEAN crear_como_servidor(void);
00072     BOOLEAN crear_como_cliente(void);
00073     int enviar(char *buffer, int tam_buffer);
00074     int recibir(char *buffer, int tam_buffer);
00075     void registro_asincronico(void (*f)(void *, int), void *User_data);
00076 };
00077 
00078 inline void
00079 CONEXION_UDP::origen(DWORD *ip, WORD *puerto)
00080 {
00081 #ifdef SOCKETS_ENABLED
00082     (*ip) = extremo_remoto.sin_addr.s_addr;
00083     (*puerto) = extremo_remoto.sin_port;
00084 #endif
00085 }
00086 
00087 inline void
00088 CONEXION_UDP::set_origen(DWORD ip, WORD puerto)
00089 {
00090 #ifdef SOCKETS_ENABLED
00091     extremo_remoto.sin_addr.s_addr = ip;
00092     extremo_remoto.sin_port = puerto;
00093 #endif
00094 }
00095 
00096 #endif // __JED_UDP__
00097 
00098 //===========================================================================
00099 //= EOF                                                                     =
00100 //===========================================================================
00101 

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.