All pastes #336325 Raw Edit

Someone

public text v1 · immutable
·published 2007-02-01 23:32 UTC
rendered paste body
#include<stdint.h>
#include<stdio.h>
#include<stdlib.h>
#include<tiuser.h>
//#include<xti.h>
#include<sys/types.h>
#include<stropts.h>
#include<stdio.h>
#include<sys/socket.h>
#include<fcntl.h>
//#include<netinet/in.h>
#include<arpa/inet.h>
int main() {
	int tfd, flags, n;
	char str[30], str1[30];
	struct t_call *callptr;
	struct sockaddr_in serv_addr;
	tfd=t_open("/dev/tcp", O_RDWR, NULL);
	t_bind(tfd, NULL, NULL);
	callptr=(void *)t_alloc(tfd, T_CALL, T_ADDR);
	serv_addr.sin_family=AF_INET;
	serv_addr.sin_port=htons(7);
	serv_addr.sin_addr.s_addr=inet_addr("127.0.0.1");
	callptr->addr.len=sizeof(serv_addr);
	callptr->addr.maxlen=sizeof(serv_addr);
	callptr->addr.buf=(char *)&serv_addr;
	callptr->opt.len=0;
	callptr->udata.len=0;
	t_connect(tfd, callptr, NULL);
	printf("Enter string: ");
	scanf("%s", str);
	t_snd(tfd, str, sizeof(str), 0);
	t_rcv(tfd, str1, sizeof(str1), &flags);
	printf("Message echoed: %s\n", str1);
	return(0);
}