473,832 Members | 2,132 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5517
The Doctor <no@email.addre sswrote in
news:49******** *************** @dreader19.news .xs4all.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.addre sswrote in message
news:49******** *************** @dreader19.news .xs4all.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.addre sswrote in
news:49******** *************** @dreader19.news .xs4all.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)

iEYEABECAAYFAkk NxLwACgkQx9p3GY HlUOK4mgCeLgoSg zeaOgVHcuNASnPl KN/Y
sCAAn3K18UZhszR nX8ifdbThXfO7DL yO
=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
17954
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 IP via InetAddress class //works on UNIX and WIN, but not on LINUX !! InetAddress hostIP = InetAddress.getLocalHost(); String hostIPStr = hostIP.getHostAddress();
10
10781
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 networked with the linux box. Is it possible for python/linux to read data from MS Access Database ?
0
1671
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 far so good. I create a packet (pkt) which contains the complete IP datagram. ID is set to 0 to tell the kernel to stamp it for me. However, I am so far unable to send the packet (pretend ']' is '>'):
3
6005
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 192.168.0.5 recv: Transport endpoint is not connected. I don't know what that means or why I am getting it. I know the connection is made by the server: message.
4
3857
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). I had some troubles when I started 6 threads (each thread made a separate connection) and sent messages to same server simultaneously. Sometimes, not always, the socket looks like ok, but really it is dead. I don't why it happens.
5
11735
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 1024 with all values set to Null arrive. Other than examine a block of 1024 to see if the entire block is null, is there any other way to determine if , say a chat message "Hi Charlie" has been received completely?
2
24284
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 the following: #include <stdlib.h> #include <stdio.h> #include <string.h> #include <errno.h> #include <netdb.h>
5
2804
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: http://williams.comp.ncat.edu/Networks/JavaSocketExample.htm This does not work when the client program is on a Linux machine. Error: Error Connection refused
1
4283
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 windows and linux by various methods. We are trying to resolve a problem of not being able to connect to the linux box from the xp machines using python XMLRPC. (This is the module used in the software I am trying to set up) Python is at 2.4...
3
11687
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' "Unix network programming" book described a TCP server (tcpcliserv04.c) and client (tcpcli04.c). I compiled and executed them successfully as follows: $ tcpcliserv04 &
0
9795
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10780
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10540
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10212
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9319
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6951
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5623
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5789
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4421
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.