00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef _TCP_H_
00011 #define _TCP_H_
00012
00013
00014 #include <stdio.h>
00015 #include <sys/types.h>
00016 #ifndef WIN32
00017 #include <sys/socket.h>
00018 #include <netdb.h>
00019 #include <unistd.h>
00020 #include <netinet/in.h>
00021 #include <sys/time.h>
00022 #include <arpa/inet.h>
00023 #else
00024 #include <windows.h>
00025 #include <winsock.h>
00026 #endif
00027 #include <string.h>
00028 #define EXIT_ERROR 0
00029 #define EXIT_OK 1
00030 #define DEFAULT_PORT 8787
00031
00032 #ifdef __cplusplus
00033 extern "C" {
00034 #endif
00035
00036 extern struct sockaddr_in srv_addr, cli_addr;
00037 extern int cli_addr_len ;
00038 extern int sSocket;
00039 extern char szerror[128];
00040 extern int nerror;
00041 extern char hostname[128];
00042
00045 int tcpstartclient(int port,
00046 char* server);
00047
00050 int tcpstartsrv(int port,
00051 int nnoc);
00052
00055 int geterror( void );
00056
00057
00058
00059 int sgeterror( void );
00060
00061
00062
00063 int tcpstop( void );
00064
00065
00066
00067 int close_socket(int mySock);
00068
00069 #ifdef __cplusplus
00070 }
00071 #endif
00072
00073 #endif // _TCP_H_
00074