recv() not workin fine.....


 
Thread Tools Search this Thread
Special Forums IP Networking recv() not workin fine.....
# 1  
Old 10-21-2005
recv() not workin fine.....

hi !

In my program I have a structure as shown below:
struct data
{
int a;
char *b;
long c;
}str;

i have assigned the following values to it:
strcpy(str.b,"John");
str.a=10;
str.c=123435;

The client is tryin to send struct data to the server using
send(sock,(char * )&str,sizeof(str),flag);

At the server side the data is read using the following:

recv(sock,(char *)&str,sizeof(str),flag);

but when i print the values on to the screen only the values of a and c get printed and b does not get printed.

The server also contains the structure.

i cant figure out y this is happening. any help is appreciated.

thanx
# 2  
Old 10-21-2005
char *b;
reseves space a a pointer to a string. No space is reserved for the string itself. You need to use something like:
char b[30];
Now you have space for a 29 character string and a terminating null.
# 3  
Old 10-23-2005
problem while sending the server sent msg to client

please anyone having the program of client server implementation server send messages to client ..please uploaded it ..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Bash regex evaluation not workin

I'm building a script that may received start and end date as parameters. I whant to make it as flexible as possible so I'm accepting epoch and date in a way that "date --date=" command may accept. In order to know if parameter provided is an epoc or a "date --date=" string I evaluate if the value... (2 Replies)
Discussion started by: lramirev
2 Replies

2. Programming

How can I tell when recv is finished with pending data?

I'm working with recv and I am having a heck of a lot of trouble ignoring excess data that I did not ask for. I was hoping someone could shine some light on the subject for me because I'm not getting anywhere fast. ---------- Post updated at 02:46 AM ---------- Previous update was at 12:31 AM... (2 Replies)
Discussion started by: Errigour
2 Replies

3. IP Networking

regarding recv function

hi, the syntax of recv function is: int recv( int sockfd, void *buffer, int length, unsigned int flags); Suppose i declared a buffer of size 100 ,then length to be specified in recv function is sizeof(buffer) or sizeof(buffer)-1 ( i.e 100 or 99) thanks in advance (2 Replies)
Discussion started by: kavitha rao
2 Replies

4. Programming

Recv() call with timer(time out )

Hi all, I am facing a problem in recv() system call i.e.. in my project i have to implement timer for sending (data) and resending purpose when there is no acknowledgement. is there any way that recv() sys call has its own timer i.e., for ex: recv() has to wait for 10 secs. if any one knows... (2 Replies)
Discussion started by: Rohil
2 Replies

5. Programming

ABOUT RECV() SYSTEM CALL (regarding timer)

Hi all, I am facing a problem in recv() system call i.e.. in my project i have to implement timer for sending (data) and resending purpose when there is no acknowledgement. is there any way that recv() sys call has its own timer i.e., for ex: recv() has to wait for 10 secs. if any... (0 Replies)
Discussion started by: Rohil
0 Replies

6. Shell Programming and Scripting

determine the periodfor which user is workin

write a shell script that determines the period for which a specified user is workin on the system. (3 Replies)
Discussion started by: shawz
3 Replies

7. Shell Programming and Scripting

why is it workin for 1 file , but not for multiple files?

Hi , this peice of code is working for one file but not for multiple files. Can some one please tell me the reason??? for i in `ls -1 | egrep ''SOM.*` ; do filename=$(ls -1 $i) filename=$(print $filename) if ] then print "Skipping file $i since it already has... (1 Reply)
Discussion started by: somanath Patrud
1 Replies

8. Shell Programming and Scripting

rsh within awk is not workin

cat input.sh | awk ' { cur1=tolower($1) cur2=tolower($2) rsh $cur1 report | grep $cur2 } ' hi, Have a look at the above code, the input.txt file contains two words in each line with space as delimiter, the first word is computer name and the 2nd word is file... (2 Replies)
Discussion started by: geeko
2 Replies

9. Programming

C Network Programming - recv() help

So I'm making a program that gets the IP Address of an inputed website, then sends the IP Address to an inputed host. This program has no real meaning, but just a learning experiment. So I sucessfully made the program, then I wanted to try out recv(), and it produces some weird output; here is the... (2 Replies)
Discussion started by: Octal
2 Replies

10. Programming

recv() problems using AIX 4.33

I am opening a server socket on one of our machines and connection to it on the other machine. After making the connection if ether one of the systems does a recv() and ther is no data to receive then the buffer is filled with spaces and returns. I have no way of knowing if it is valid or not. ... (1 Reply)
Discussion started by: hazard0007
1 Replies
Login or Register to Ask a Question