Sponsored Content
Full Discussion: Socket Keep-Alive
Top Forums Programming Socket Keep-Alive Post 302972018 by Projecteer on Thursday 28th of April 2016 02:12:58 PM
Old 04-28-2016
thanks for looking & solving. Yes I see now the recv loop should read a stream and work out when to stop pulling more bytes from recv(), In my full code I extract the chucked hex later for decompressing gzip, I'll have to read the header & chunk in the while(recv loop.

When i read about keep-alive I believe the Apache server is meant to wait for timout of at least 5 seconds (after handling a request), but my recv loop finishes pretty instantly after recieving 3-4 HTTP packets for the entire gzip webpage (in my full code).

I'm guessing somehow the server sees a request for more information and Apache has code to detect clients with while(recv() != 0).

Last edited by Projecteer; 04-28-2016 at 03:18 PM..
 

9 More Discussions You Might Find Interesting

1. Programming

HTTP Keep-Alive socket problem

Hello everyone, I am a newbie in UNIX/Linux socket programming. This is a class project that I had trouble with. ================================================== I was trying to make “Keep-Alive” HTTP connections to the server in a tiny web crawler project. Here is the problem: when I tried... (0 Replies)
Discussion started by: imdupeng
0 Replies

2. UNIX for Dummies Questions & Answers

Socket still alive!!

Hi, I'm investigate about a problem regarding a connection between two server (S1 and S2). A client software on S1 made a pool of connections on S2; for some reason some connections end but sockets still alive on S2 and not on S1. I always knew about sockets as a pair of processes; is it... (1 Reply)
Discussion started by: grado
1 Replies

3. Shell Programming and Scripting

Can we keep our script alive while logging out.

Hi I want to keep my script running even when i am logged off from the box. can we run the script in background which can automatically run every hour? Please advise. Thank you (1 Reply)
Discussion started by: Prateek007
1 Replies

4. UNIX for Advanced & Expert Users

connect problem for sctp socket (ipv6 socket) - Runtime fail Invalid Arguments

Hi, I was porting ipv4 application to ipv6; i was done with TCP transports. Now i am facing problem with SCTp transport at runtime. To test SCTP transport I am using following server and client socket programs. Server program runs fine, but client program fails giving Invalid Arguments for... (0 Replies)
Discussion started by: chandrutiptur
0 Replies

5. Programming

which socket should socket option on be set

Hi all, On the server side, one socket is used for listening, the others are used for communicating with the client. My question is: if i want to set option for socket, which socket should be set on? If either can be set, what's the different? Again, what's the different if set option... (1 Reply)
Discussion started by: blademan100
1 Replies

6. Programming

socket function to read a webpage (socket.h)

Why does this socket function only read the first 1440 chars of the stream. Why not the whole stream ? I checked it with gdm and valgrind and everything seems correct... #include <stdio.h> #include <stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <string.h> #include... (3 Replies)
Discussion started by: cyler
3 Replies

7. Programming

Error with socket operation on non-socket

Dear Experts, i am compiling my code in suse 4.1 which is compiling fine, but at runtime it is showing me for socket programming error no 88 as i searched in errno.h it is telling me socket operation on non socket, what is the meaning of this , how to deal with this error , please... (1 Reply)
Discussion started by: vin_pll
1 Replies

8. IP Networking

Clarification - Setting socket options at the same time when socket is listening

I need clarification on whether it is okay to set socket options on a listening socket simultaneously when it is being used in an accept() call? Following is the scenario:- -- Task 1 - is executing in a loop - polling a listen socket, lets call it 'fd', (whose file descriptor is global)... (2 Replies)
Discussion started by: jake24
2 Replies

9. What is on Your Mind?

Is this forum alive?

Odd thing. I posted in the Solaris forum, new user, just asking for a bit of advice. Nothing too complicated. As of this post there have been 140 views and zero replies. So that got me thinking, is this normal? I had a look around, and I see the same thing on many other threads, and in other... (2 Replies)
Discussion started by: _JonB_
2 Replies
SOCKATMARK(3)						     Linux Programmer's Manual						     SOCKATMARK(3)

NAME
sockatmark - determine whether socket is at out-of-band mark SYNOPSIS
#include <sys/socket.h> int sockatmark(int sockfd); Feature Test Macro Requirements for glibc (see feature_test_macros(7)): sockatmark(): _POSIX_C_SOURCE >= 200112L DESCRIPTION
sockatmark() returns a value indicating whether or not the socket referred to by the file descriptor sockfd is at the out-of-band mark. If the socket is at the mark, then 1 is returned; if the socket is not at the mark, 0 is returned. This function does not remove the out-of- band mark. RETURN VALUE
A successful call to sockatmark() returns 1 if the socket is at the out-of-band mark, or 0 if it is not. On error, -1 is returned and errno is set to indicate the error. ERRORS
EBADF sockfd is not a valid file descriptor. EINVAL sockfd is not a file descriptor to which sockatmark() can be applied. VERSIONS
sockatmark() was added to glibc in version 2.2.4. ATTRIBUTES
For an explanation of the terms used in this section, see attributes(7). +-------------+---------------+---------+ |Interface | Attribute | Value | +-------------+---------------+---------+ |sockatmark() | Thread safety | MT-Safe | +-------------+---------------+---------+ CONFORMING TO
POSIX.1-2001, POSIX.1-2008. NOTES
If sockatmark() returns 1, then the out-of-band data can be read using the MSG_OOB flag of recv(2). Out-of-band data is supported only on some stream socket protocols. sockatmark() can safely be called from a handler for the SIGURG signal. sockatmark() is implemented using the SIOCATMARK ioctl(2) operation. BUGS
Prior to glibc 2.4, sockatmark() did not work. EXAMPLE
The following code can be used after receipt of a SIGURG signal to read (and discard) all data up to the mark, and then read the byte of data at the mark: char buf[BUF_LEN]; char oobdata; int atmark, s; for (;;) { atmark = sockatmark(sockfd); if (atmark == -1) { perror("sockatmark"); break; } if (atmark) break; s = read(sockfd, buf, BUF_LEN); if (s == -1) perror("read"); if (s <= 0) break; } if (atmark == 1) { if (recv(sockfd, &oobdata, 1, MSG_OOB) == -1) { perror("recv"); ... } } SEE ALSO
fcntl(2), recv(2), send(2), tcp(7) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. Linux 2017-09-15 SOCKATMARK(3)
All times are GMT -4. The time now is 04:37 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy