The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Special Forums > IP Networking
.
google unix.com



IP Networking Learn TCP/IP, Internet Protocol, Routing, Routers, Network protocols in this UNIX and Linux forum.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
reverse an integer ali560045 Shell Programming and Scripting 4 05-20-2008 04:15 AM
Cannot store integer value bennichan Shell Programming and Scripting 5 04-10-2008 03:20 PM
get integer part ericaworld Shell Programming and Scripting 3 05-29-2007 04:16 PM
pf not working properly even with only "pass in all" and "pass out all" rules xyyz UNIX for Advanced & Expert Users 4 12-30-2003 05:33 AM
integer arrays primal High Level Programming 4 03-09-2002 05:40 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 08-25-2005
ramneek ramneek is offline
Registered User
  
 

Join Date: Aug 2005
Posts: 30
how to pass integer

i am writing a client and server program

client program

main()

{
int sockfd,n;
char str[20];
struct sockaddr_in sock;

if ((sockfd=socket(AF_INET,SOCK_STREAM,0))<0)
{
perror("SOCKET ERROR");
}


bzero(&sock,sizeof(sock));

sock.sin_family=AF_INET;
sock.sin_port=7500;
sock.sin_addr.s_addr=inet_addr("192.127.137.251");

if(connect(sockfd,(struct sockaddr*)&sock,sizeof(sock))<0)
{
perror("CONNECT ERROR :");
}

strcpy(str,"i am here");
write(sockfd,(char *)str,strlrn(str)+1);

//close(sockfd);

socket program

main()
{
int sockfd,connfd,clientlen;
char str[20];
struct sockaddr_in sock,client;


if((sockfd=socket(AF_INET,SOCK_STREAM,0))<0)
{
perror("SOCKET ERROR ");
}


bzero(&sock,sizeof(sock));

sock.sin_family=AF_INET;
sock.sin_port=7500;
sock.sin_addr.s_addr=inet_addr("192.127.137.251");

if((bind(sockfd,(struct sockaddr*)&sock,sizeof(sock)))<0)
{
perror("BIND ERROR:");
}


listen(sockfd,3);

clientlen=sizeof(client);

if((connfd=accept(sockfd,(struct sockaddr*)&client,&clientlen))<0)
{
perror("CONNECTION ERROR :");
}



read(connfd,(char *)str,20);
printf("%s ",str);

close(connfd);
close(sockfd);
}




now the problem is i have to pass a integer or bool variable rather than string
how can i do this
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:52 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0