发表于:2004-08-11 10:23:00
10楼
//代码简化过的.看起来应该容易一些
// DEMO2: Client read/write server
// File name: demo2.c
// Compile mode: large
#define ES2_DEBUG 2 /* unmark to show debug information */
#include <string.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include "..\lib\7188e.h"
#include "..\lib\tcpip.h"
#define BUFSIZE 1024 /* read/write buffer size */
#define SERVICE 10000 /* define the service port for Server */
#define SOCKETS 32 /* define the maximum number of sockets */
#define QLEN SOCKETS-1 /* maximum connection queue length */
void killsockets(void);
int do_echo( int skt );
int es; /* flag to run ES (service loop) */
fd_set rfds; /* set of socket file descriptors for reading */
typedef struct socket_state
{
int active; /* socket is active */
int init; /* socket just initiated */
struct sockaddr_in sin; /* client address */
} socket_state;
socket_state sst[SOCKETS]; /* sockets state table */
/*************************************************************************
* main
* program main routine
*************************************************************************/
int RxCounter=0;
int RxCounterOut=0;
struct ip host_ip = { {192,168,255,2},{255,255,0,0} };
main( int argc, char *argv[] )
{
struct sockaddr_in ssin; /* client Internet endpoing address */
int sin_len; /* length of sockaddr_in */
int s; /* master socket for listenning */
int ss; /* slave socket got from accept */
int type, protocol, err=0;
int rc; /* return code of selectsocket */
int i;
char Message1[]="connected successful.";