[ create a new paste ] login | about

Link: http://codepad.org/w4zd0J0t    [ raw code | output | fork ]

C, pasted on Nov 17:
/* 
	server1.c
	This is a sample for a server code using socket API.
	(c) M. Okada
*/

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "INExp.h"

#define BLEN 100
#define PORT 1201

int soc;
char buf[BLEN];

int main(void){

	int i;
	char init[BLEN] = "";
	for( i = 0 ; i < BLEN ; ++i ){ strcat( init, "¥0" ); }

	if(( soc=setup_server(PORT))==-1){
		exit( EXIT_FAILURE );
	}
	printf("SAMPLE Server Start.¥n");
	strcpy(buf,"This is Server1.¥n");
	write(soc,buf,strlen(buf));
	strncpy(buf,init,BLEN);
	while(1){
		read(soc, buf, BLEN);
		printf("%s %d characters¥n",buf,strlen(buf)-2); /* -2 、マ /r/n */
		if(strncmp(buf,"¥¥end¥r¥n",6)==0
		  || strncmp(buf,"¥¥END¥r¥n",6)==0){
			break;
		}
		write(soc, buf, strlen(buf));
	        strncpy(buf,init,BLEN);
	}
	strcpy(buf,"Bye bye!!¥n");
	write(soc,buf,strlen(buf));
	close_server(soc);
	printf("SAMPLE Server Terminated.¥n");
        return EXIT_SUCCESS;
}


Output:
1
Line 18: error: INExp.h: No such file or directory


Create a new paste based on this one


Comments: