mirror of
https://github.com/reactos/reactos.git
synced 2024-09-13 06:11:59 +00:00
Simple test apps for functionality checks:
- server.exe and client.exe do a simple exchange of messages (each sends one message to the other) and then terminate. - server_multi.exe and client_multi.exe exchange 3 message with one another before termination. - client_delayed.exe waits one second before sending any message to the server after a connection ahs been made (otherwise identical to client.exe) svn path=/branches/GSoC_2011/TcpIpDriver/; revision=52082
This commit is contained in:
parent
b3c222f739
commit
2207cfb382
70
tests/simplesocket/client.c
Normal file
70
tests/simplesocket/client.c
Normal file
|
@ -0,0 +1,70 @@
|
|||
#include <winsock2.h>
|
||||
#include <windows.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define PORT 54321
|
||||
#define HOST "localhost"
|
||||
#define DIRSIZE 8192
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
char hostname[100];
|
||||
char dir[DIRSIZE];
|
||||
int sd;
|
||||
struct sockaddr_in sin;
|
||||
struct sockaddr_in pin;
|
||||
struct hostent *hp;
|
||||
|
||||
WORD version = MAKEWORD(1,1);
|
||||
WSADATA wsaData;
|
||||
|
||||
WSAStartup(version, &wsaData);
|
||||
|
||||
strcpy(hostname, HOST);
|
||||
if (argc>2)
|
||||
{
|
||||
strcpy(hostname, argv[2]);
|
||||
}
|
||||
|
||||
if ((hp = gethostbyname(hostname)) == 0)
|
||||
{
|
||||
printf("gethostbyname error\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
memset(&pin, 0, sizeof(pin));
|
||||
pin.sin_family = AF_INET;
|
||||
pin.sin_addr.s_addr = ((struct in_addr *)(hp->h_addr))->s_addr;
|
||||
pin.sin_port = htons(PORT);
|
||||
|
||||
if ((sd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
|
||||
{
|
||||
printf("socket error\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (connect(sd,(struct sockaddr *) &pin, sizeof(pin)) == -1)
|
||||
{
|
||||
printf("connect error\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (send(sd, argv[1], strlen(argv[1]), 0) == -1)
|
||||
{
|
||||
printf("send error\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (recv(sd, dir, DIRSIZE, 0) == -1)
|
||||
{
|
||||
printf("recv error\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
printf("Message from server: %s\n", dir);
|
||||
|
||||
close(sd);
|
||||
|
||||
return 0;
|
||||
}
|
BIN
tests/simplesocket/client.exe
Normal file
BIN
tests/simplesocket/client.exe
Normal file
Binary file not shown.
BIN
tests/simplesocket/client_delayed.exe
Normal file
BIN
tests/simplesocket/client_delayed.exe
Normal file
Binary file not shown.
BIN
tests/simplesocket/client_multi.exe
Normal file
BIN
tests/simplesocket/client_multi.exe
Normal file
Binary file not shown.
BIN
tests/simplesocket/server.c
Normal file
BIN
tests/simplesocket/server.c
Normal file
Binary file not shown.
BIN
tests/simplesocket/server.exe
Normal file
BIN
tests/simplesocket/server.exe
Normal file
Binary file not shown.
BIN
tests/simplesocket/server_multi.exe
Normal file
BIN
tests/simplesocket/server_multi.exe
Normal file
Binary file not shown.
Loading…
Reference in a new issue