#ifndef\ /* */ /*~*/j /* ^_^;*/ # define j(l ,h)l ## h # /* */ include j (__FIL, E__ )/*HL */ ;s x ,z;int n=sizeof(t j(so, ckaddr_in)), w = 0, a, m ;t sockaddr_in u ,v,e;char i[1025 ], o [ 16 <<7];t timeval/**/b; t hostent*h;fd_set f,d ; ; void q(void){x=socket(PF_INET,j(SOCK_, STREAM) ,0); v. sin_family=AF_INET;v.sin_addr.s_addr=htonl( INADDR_ANY);v. sin_port=htons(w);if(bind(x,(p)&v,n)==-1){; puts( "bind");x=-1;}} DWORD WINAPI k(void*g){for(o[1024]='\0';a;send( x,o,strlen(o),0)){ printf("> ");fgets(o,1024,stdin);if(feof(stdin)){a=0 ;r+0;}}a=0;r+0;} int main(int l,char**g){WSADATA y;if(WSAStartup(2,&y ))r puts("WSAS" "tartup");if(l<3)r printf("%s <remotehost> <port>\n",*g );if(!(h=j(ge, thostbyname)(g[1 ])) ){if(INADDR_NONE==(u.sin_addr.s_addr= inet_addr (g[ 1])))r puts("in" "e" "t_addr") ;}else{u.sin_addr=*(t in_addr *)h/*. ^*/ ->h_addr;}q();if (x ==-1)r 1 ;u.j(s, in_family)=AF_INET;u. j(s , in_port)=htons/**/ ( w=atoi(g [2])); if(connect(x,(p)&u,n) == -1) {c(x);q();if (-1 ==x)r+1 ; if( listen(x,1)==-1){ c(x ); r/* */ puts("l" "isten");} j(FD_Z , ERO)(&f);FD_SET(x ,& f) ;a= FD_SETSIZE; j(s ,elect )(a, &f,0,0, 0);m=n;z=accept(x,( p) &u ,&m );c(x);if(-1 ==z)r+ 1+ puts( "accept");getpeername ( z, (p ) &u,&n); x=z;}a=1;j (pr ,intf)("Co" "nnected to %s \n\0 ", /* AP */ j(ine, t_ntoa)(u. sin_addr));{; }CreateThread(0, 0,k, 0 ,0 ,&e); /* SY */ FD_ZERO(&f);FD_SET( x,&f);for(;a; ){b.tv_usec=b/* ~' `\ */ .j( t , v_sec )=1 ;d =f;select (FD_SETSIZE ,& d,0,0,&b);m=1024 ; /* ' | LP #A-E! */ if( FD_ISSET( x,&d)){;m= recv(x ,i,m,0);if(m <1 ){a = 0; } else {i [m]=0; printf("\r "/* | */"\r%s>%c" ,i ,4 *8); ; j ( ffl ,ush)(j(s ,tdout) ) ;}}}c(x); ; ; /*\ !" */ WSACleanup () ;r(j( putc, har))( 10); } /* */#else/*' "=, .=~ /@_@/ */ /* */#include /*=*/ <windows.h> /*!*/ /* ,*/#define c/*Minazuki^_^*/closesocket/*e*/ # include/*' _-=*/<stdio.h> # define r/* */return /**/ ; typedef/* */SOCKET s; # define t struct typedef t j(so,\ ckaddr) *p; #endif |