


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <dos.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>

#include "sckstdio.h"



main(int argc, char *argv[])
	{
	int s,n;
	FILE *fp;
	FILE *sin,*sout;
	struct sockaddr_in servaddr;
	struct hostent *he;
	int bit,writebit,readbit,exceptbit=0,iobit;

	so_init();

	s = socket(AF_INET, SOCK_STREAM, 0);

	if (!(he = gethostbyname("spam")))
		{
		printf("Failed 1\n");
		return;
		}

	servaddr.sin_family = he->h_addrtype;
	servaddr.sin_port = htons(25);
	memcpy(&servaddr.sin_addr,he->h_addr_list[0],he->h_length);

	printf("Trying... %s\n",inet_ntoa(servaddr.sin_addr));

	if (connect(s, (struct sockaddr *)(&servaddr),sizeof(servaddr)) == -1)
		{
		printf("Failed\n");
		return;
		}

	iobit = writebit = readbit = bit = 1L<<s;
	iobit = select(s+1,(struct fd_set *)&readbit,(struct fd_set *)&writebit,(struct fd_set *)&exceptbit,NULL);	/* Get read/write status */

	if (iobit>0)
		{
		if (send(s,"Wobber wobbber\n",strlen("Wobber wobber\n")+1,0)<=0)
			{
			printf("Failed 2\n");
			}
		}
	else printf("Can't write\n");

	iobit = writebit = readbit = bit = 1L<<s;
	iobit = select(s+1,(struct fd_set *)&readbit,(struct fd_set *)&writebit,(struct fd_set *)&exceptbit,NULL);	/* Get read/write status */

	so_close(s);

	so_exit();
	}

