Underground - Bhasker V K,the Sandman's Hideout

Thanks for dropping in...I got this running since i needed a place to post info that i found interesting which,i could access online .lotta stuff here might find a few glances ...so make ur self @ home...and hope u find the links/info ur looking for or atleast giv u a hint 'what you should ' be looking for .
Keep Clicking,
Bhasker V K
VoyForums

VoyUser Login optional ] [ Contact Forum Admin ] [ Main index ] [ Post a new message ] [ Search | Check update time | Archives: 1 ]
Subject: time


Author:
bhasker
[ Next Thread | Previous Thread | Next Message | Previous Message ]
Date Posted: 01:15:19 08/17/05 Wed
Author Host/IP: NoHost/202.71.147.34

#include
#include
int main()
{
time_t ticks;
char buff[100];
ticks =time(NULL);
printf("%.24s\r\n",ctime(&ticks));
}
*******************************************************
now sending the date over a connection.

CODE:

#include
#include
#include
#include
#include
#include
int main()
{
int servSock,connSock;
int childPID;
int len;
time_t ticks;
char buff[100];
struct sockaddr_in cliaddr,servaddr;
int PORT =7890;

servSock=socket(AF_INET,SOCK_STREAM,0);

bzero(&servaddr,sizeof(servaddr));
servaddr.sin_family = AF_INET;
servaddr.sin_addr.s_addr=htonl(INADDR_ANY);
servaddr.sin_port=htons(PORT);

bind(servSock,(struct sockaddr*) &servaddr,sizeof(servaddr));

listen(servSock,5);

for(;;)
{
len=sizeof(cliaddr);
connSock=accept(servSock,(struct sockaddr*)&cliaddr,&len);

ticks =time(NULL);
snprintf(buff,sizeof(buff),"%.24s\r\n",ctime(&ticks));

write(connSock,buff,strlen(buff));


close(connSock);
}
}


***********************
Cllient side
CODE:

#include
#include
#include
#include
#include
#include

int main(int argc,char **argv)
{

int sockfd;
char Str[100];
struct sockaddr_in servaddr;

sockfd=socket(AF_INET,SOCK_STREAM,0);
if(sockfd<0)
printf("error in sock creation");

bzero(&servaddr,sizeof(servaddr));
servaddr.sin_addr.s_addr = inet_addr("172.16.3.25");
servaddr.sin_family=AF_INET;
servaddr.sin_port=htons(7890);
//inet_pton(AF_INET,argv[1],&servaddr.sin_addr);

connect(sockfd,(struct sockaddr*)&servaddr,sizeof(servaddr));

read(sockfd,Str,100);

printf("%s",Str);

exit(0);
}

[ Next Thread | Previous Thread | Next Message | Previous Message ]


VoyUser Login ] Not required to post.
Post a public reply to this message | Go post a new public message
* Notice: Posting problems? [ Click here ]
* HTML allowed in marked fields.
Message subject (required):

Name (required):

  Expression (Optional mood/title along with your name) Examples: (happy, sad, The Joyful, etc.) help)

  E-mail address (optional):

* Type your message here:

Choose Message Icon: [ View Emoticons ]

Notice: Copies of your message may remain on this and other systems on internet. Please be respectful.

[ Contact Forum Admin ]

"
"
Forum timezone: GMT-8
VF Version: 2.94, ConfDB:
Before posting please read our privacy policy.
VoyForums(tm) is a Free Service from Voyager Info-Systems.
Copyright © 1998-2008 Voyager Info-Systems. All Rights Reserved.
if u want to post ,send an email to bosky101@indiatimes.com ..this is to maintain the integrity of this forum ..cheers
Keep Clicking,
bosky101 Click here to listen to my music station