473,326 Members | 2,134 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Linux socket + real-time signals

Hey people,

I have two applications:

the server, which creates a server socket, waits for a real-time signal,
and if it receives one, it creates a client socket.

The client, which will connect to the server. This will generate a real-
time signal at the server, who will create a client socket for this
client.

This all works well, and I see a client appearing at my server, on a
connection attempt. But then, the client tries to send the server-side
client socket some data. This is where it all goes wrong. The client
sends, but sometimes, the server doesn't receive it. The weird thing is,
it receives it when the client is killed. Some other times, the
application just works, and the server receives the data at the moment it
is sent from the client.

I think this could be some problem with an output buffer at the client or
so? Is there anyone who knows what the problem is?

Grtz, The Doctor
Nov 2 '08 #1
4 5454
The Doctor <no@email.addresswrote in
news:49***********************@dreader19.news.xs4a ll.nl:
Hey people,

I have two applications:

the server, which creates a server socket, waits for a real-time
signal, and if it receives one, it creates a client socket.

The client, which will connect to the server. This will generate a
real- time signal at the server, who will create a client socket for
this client.

This all works well, and I see a client appearing at my server, on a
connection attempt. But then, the client tries to send the server-side
client socket some data. This is where it all goes wrong. The client
sends, but sometimes, the server doesn't receive it. The weird thing
is, it receives it when the client is killed. Some other times, the
application just works, and the server receives the data at the moment
it is sent from the client.

I think this could be some problem with an output buffer at the client
or so? Is there anyone who knows what the problem is?

Grtz, The Doctor

I believe this may be off-topic.

To (attempt) to answer your question: Have you tried either manually
flushing the client socket, or setting TCP_NODELAY on it? (to force the
socket to send the data right away).
Best Regards
JL
Nov 2 '08 #2
Hi,
Have you read the socket FAQ?

http://www.unixguide.net/network/socketfaq/

Also make sure you handle interrupted calls correctly (depending how you
read) For instance read might return when an interrupt is received (EINTR).

Regards, Ron AF Greve

http://www.InformationSuperHighway.eu

"The Doctor" <no@email.addresswrote in message
news:49***********************@dreader19.news.xs4a ll.nl...
Hey people,

I have two applications:

the server, which creates a server socket, waits for a real-time signal,
and if it receives one, it creates a client socket.

The client, which will connect to the server. This will generate a real-
time signal at the server, who will create a client socket for this
client.

This all works well, and I see a client appearing at my server, on a
connection attempt. But then, the client tries to send the server-side
client socket some data. This is where it all goes wrong. The client
sends, but sometimes, the server doesn't receive it. The weird thing is,
it receives it when the client is killed. Some other times, the
application just works, and the server receives the data at the moment it
is sent from the client.

I think this could be some problem with an output buffer at the client or
so? Is there anyone who knows what the problem is?

Grtz, The Doctor

Nov 2 '08 #3
On Sun, 02 Nov 2008 07:22:41 -0600, John Lampe wrote:
The Doctor <no@email.addresswrote in
news:49***********************@dreader19.news.xs4a ll.nl:
>Hey people,

I have two applications:

the server, which creates a server socket, waits for a real-time
signal, and if it receives one, it creates a client socket.

The client, which will connect to the server. This will generate a
real- time signal at the server, who will create a client socket for
this client.

This all works well, and I see a client appearing at my server, on a
connection attempt. But then, the client tries to send the server-side
client socket some data. This is where it all goes wrong. The client
sends, but sometimes, the server doesn't receive it. The weird thing
is, it receives it when the client is killed. Some other times, the
application just works, and the server receives the data at the moment
it is sent from the client.

I think this could be some problem with an output buffer at the client
or so? Is there anyone who knows what the problem is?

Grtz, The Doctor


I believe this may be off-topic.

To (attempt) to answer your question: Have you tried either manually
flushing the client socket, or setting TCP_NODELAY on it? (to force the
socket to send the data right away).
Best Regards
JL
How do I manually flush a socket?

Grtz, The Doctor
Nov 2 '08 #4
Sam
The Doctor writes:
Hey people,

I have two applications:

the server, which creates a server socket, waits for a real-time signal,
and if it receives one, it creates a client socket.

The client, which will connect to the server. This will generate a real-
time signal at the server, who will create a client socket for this
client.

This all works well, and I see a client appearing at my server, on a
connection attempt. But then, the client tries to send the server-side
client socket some data. This is where it all goes wrong. The client
sends, but sometimes, the server doesn't receive it. The weird thing is,
it receives it when the client is killed. Some other times, the
application just works, and the server receives the data at the moment it
is sent from the client.

I think this could be some problem with an output buffer at the client or
so? Is there anyone who knows what the problem is?
Your problem has nothing to do with C++, the language. There is no such
thing as a "socket", or a "real time signal" defined by the C++ language.

Furthermore, your usage of "real time signal" is unclear, as well. All
signals in POSIX are "real time", whatever that means.

Your problem is likely to do with the interaction of signals, and socket
I/O. It is notoriously difficult to get this right. There are many race
conditions that can potentially occur. Generally, signal handling, and
socket I/O do not mix very well.

I forget whether it was 2.6.25 or 2.6.26, but recently an implementation of
non-POSIX standard API for signal handling with file descriptors was added
to the Linux kernel. Signal events are reported through a file descriptor,
so you can have a combined poll()/select() call that processes either
traditional file descriptor activity, or signal events, whichever one
occurs. This eliminates the whole slew of race conditions present in
classical signal handling, and makes many things much easier to do. You
should look into it, but, again, this has nothing to do with C++, the
language.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEABECAAYFAkkNxLwACgkQx9p3GYHlUOK4mgCeLgoSgzeaOg VHcuNASnPlKN/Y
sCAAn3K18UZhszRnX8ifdbThXfO7DLyO
=moFd
-----END PGP SIGNATURE-----

Nov 2 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: gurtd_dauberie | last post by:
I can't get the correct IP address on Linux... The following code works properly on Windows and Unix. But on Linux, I always get the Loopback Address (127.0.0.1) Here is the code : //gets the...
10
by: David ROBERT | last post by:
Hello, I need to read data from a MS Access database. The program (reader) is installed on a linux box and is written in python langage. The database is MS Access 2002 installed on a Win XP box...
0
by: Mike Ayers | last post by:
I am trying to compose raw IP packets on Linux, then send them out a chosen interface. So I do: sock = socket.socket( socket.AF_PACKET, socket.SOCK_DGRAM ) sock.bind(( '192.168.1.3' )) So...
3
by: Robert Smith | last post by:
As you can tell by my code that I will post I am obviously new with linux socket programming so to be to hard on me :) When I run my little program I get this error: Server: got connection from...
4
by: Frank Meng | last post by:
Hi. I am trying a csharp sample from http://www.codeproject.com/csharp/socketsincs.asp . (Sorry I didn't post all the source codes here, please get the codes from above link if you want to try)....
5
by: mscirri | last post by:
The code below is what I am using to asynchronously get data from a PocketPC device. The data comes in fine in blocks of 1024 bytes but even when I send no data from the PocketPC constant blocks of...
2
by: dariophoenix | last post by:
Hi, I am trying to encapsulate Linux sockets and POSIX threads in C++ classes (I work in Knoppix, using KDevelop). Since sockets and threads are new to me, I searched for example code and found...
5
by: ganeshp | last post by:
Hi , In Java using socket programming is it possible to have a server program on windows that services a client program on linux? I tried the code in the below given link:...
1
by: getafixx | last post by:
Hello everyone, We have a linux server (Fedora core 7, default install, firewall turned off) and a bunch of windows XP machines on network/domain. All machines are visible and I can get to both...
3
by: TsanChung | last post by:
I want to make a java TCP socket client to communicate with a TCP server socket on linux. Are there some sample C unix server and java client socket programs available? The Richard Stevens'...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.