Help receiving a frame in C!


 
Thread Tools Search this Thread
Top Forums Programming Help receiving a frame in C!
# 1  
Old 07-23-2009
Help receiving a frame in C!

Hello everybody,
I have a problem with a program i'm coding, the thing is that i need the program to check quickly if it receives a response, if not, just go ahead.

My program sends the frame successfully, but it keeps waiting for the response until it receives something. That's what i need to fix, i mean, how do i do to wait for a response just, let's say 100 nanoseconds, and break the "listening" if no response is received in that period of time?

Here's part of the code:

Code:
...
if((length=recvfrom(recv_sock,&f,ETH_FRAME_LEN,0,NULL,NULL))<0){
close(send_sock);
return(NON_OK);
}
if(ntohs(f.arp_opcode)==operation){
printf("received!\n");
}


Please excuse my poor english. Thanks.
Zykl0n-B
# 2  
Old 07-24-2009
Set Receive Timeout
Try this
Code:
socklen_t optval;
struct timeval tv;

tv.tv_sec=5;
tv.tv_usec = 0;
optval=sizeof(tv);

     int ret = setsockopt(recv_sock,SOL_SOCKET, SO_RCVTIMEO,&tv,optval);
     if( ret < 0 )
        printf("Sorry - setsockopt failed");

# 3  
Old 07-24-2009
That's it!!! Thank you, Johnbach!!! Thank you!
Zykl0n-B
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. AIX

AIX Frame: NIC port down

NIC port is down on IBM Frame. From the back its slot C7/C8. The network switch is the problem, and a new switch will be coming into play. There's one VIO and one LPAR. How do i tell the port is down in the OS on the VIO? And how can i verify it's backup without pulling cables? We have a... (1 Reply)
Discussion started by: gps1976
1 Replies

2. Hardware

Faulty parts in a frame

Hello, Following parts need to be replaced in a frame as suggested by IBM 1. Flexible Cable 2. Service Processor Card Would these faulty parts impact all lpars which are there in this frame? Best regards, Vishal (5 Replies)
Discussion started by: admin_db
5 Replies

3. Shell Programming and Scripting

CGI Perl : only frame is getting updated

I am working on CGI perl and trying to overcome the below problem.. I have divided the page into 3 frames( attached the screenshot) how to my frameset look like. In frame2, there will be a cgi script consisting on names(links), when clicked on link , the frame3 should get changed. But in... (1 Reply)
Discussion started by: scriptscript
1 Replies

4. Programming

Build an Ethernet Frame in C

Hi, I must build an ethernet frame in C! How I can do it? (7 Replies)
Discussion started by: prompt
7 Replies

5. Web Development

buttons links in frame

Happy X-Mas to all members... Hi, I have one html file page1.html as below <HTML> <HEAD> <TITLE>Utilities</TITLE> </HEAD> <FRAMESET ROWS="5%,95%"> <FRAME SRC="frames1.html" NAME=SIDEBAR> <FRAME SRC="frames2.html" NAME=SAMPLE> </FRAMESET> </HTML> ... (0 Replies)
Discussion started by: villain41
0 Replies

6. Shell Programming and Scripting

form results in frame

I used a script posted here to get my form results in a frame; which works great on first submit, BUT, creates a new set of frames in the form window on second submit. I've set the targets to the frame names. Anyone have any suggestions? thank you! (2 Replies)
Discussion started by: walkacrossfire
2 Replies

7. UNIX for Advanced & Expert Users

removing frame charecters

Hi I have a requirement as follows. My Input file is as follows. COL1,COL2,COL3,COL4,COL5 987,2,3~7~5,400~468~598,0005~4687~5980 1111,2,2~7,400~468,0005~897 Expected OUTPUT ============ COL1,COL2,COL3,COL4,COL5 987,2,3,400,0005 987,2,7,468,4687 987,2,5,598,5980 1111,2,2,400,0005... (6 Replies)
Discussion started by: tkbharani
6 Replies

8. Shell Programming and Scripting

frame multiple lines into one

Hi, i have a file with contents like below ( any number of entries can be there) 111 222 333 444 555 i need to make another file with single line like below: 111,222,333,444,555 (without ending , ) TIA Prvn (8 Replies)
Discussion started by: prvnrk
8 Replies

9. Programming

Frame buffer implementation in Linux

At present, Iam working on Linux Framebuffer device console. I have a doubt sir. Please solve this. *How to display a string or a character in Frame buffer in C language? *What is the library file (is it <linux/fb.h> or other one?) used to do all I/O function manipulations like printing,... (0 Replies)
Discussion started by: chandra80
0 Replies
Login or Register to Ask a Question