473,395 Members | 1,403 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,395 software developers and data experts.

Unix sockets help

Hi,

I am working on a c++ project involving sockets and threads and I need
to ask a pretty basic question.

If you have a socket that every time it accepts a connection
(accept()) it spawns a thread with the identifier returned by accept
where the thread will write to the identifier using send().

My question is, are those identifiers returned by accept unique and
reliable enough s.t I can write (using send()) to them simultaneously
OR do I need a mutex on the writing code so that I don`t write to the
same physical socket by different sockets at the same time?

The current problem is that on the client side, I expect data like 123
and abc (for 2 different clients) and I am getting 1b3 and a2c, sort
of mixed data so that prompted me to ask this question.

Thanks.

Feb 25 '07 #1
1 1514
Karim wrote:
Hi,

I am working on a c++ project involving sockets and threads and I need
to ask a pretty basic question.

If you have a socket that every time it accepts a connection
(accept()) it spawns a thread with the identifier returned by accept
where the thread will write to the identifier using send().

My question is, are those identifiers returned by accept unique and
reliable enough s.t I can write (using send()) to them simultaneously
OR do I need a mutex on the writing code so that I don`t write to the
same physical socket by different sockets at the same time?

The current problem is that on the client side, I expect data like 123
and abc (for 2 different clients) and I am getting 1b3 and a2c, sort
of mixed data so that prompted me to ask this question.
comp.lang.c++ is not the right news group. Try comp.unix.programmer.

To answer your question - the "file descriptor" returned by accept is
unique to all the other "OPEN" file descriptors.

If you have a *nix system, there usually is a system call tracker
(strace on Linux). Trace the process (and threads) and you should get a
clear indication of what is going on.

But don't post system specific questions on comp.lang.c++. This NG is
specifically for the C++ language.
Feb 25 '07 #2

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

Similar topics

1
by: Robert PADOVANO | last post by:
Hello, I wish to establish a connection in language PHP on a UNIX server by telnet. In fact, I would like : - Connect to server by sending IP adress, login, password - Send an order (example:...
1
by: afalanga | last post by:
Hi, I seem to be unable to connect to my PostgreSQL database over UNIX domain sockets, i.e. pg_connect("dbname=mydb"); No matter what I do to the pg_hba.conf file, or anything else, PHP...
0
by: Joseph Dionne | last post by:
I thought I read somewhere that version 1.5 was adding support for Unix domain sockets. Has support been added as yet? Joseph
5
by: Fossie | last post by:
Hi folks, I am unable to solve the following problem, which should not be new, but I cannot find an appropriate solution anywhere: One python process ("daemon") waits for messages. Another...
5
by: Virgil Green | last post by:
An associate has asked me to take a look a problem he's having with starting mysql. I thought I'd give it a shot to learn some more about mySQL before having him turn it over to someone more...
4
by: Alex Martinoff | last post by:
Using the org.postgresql.Driver JDBC driver is it possible to connect to Postgres using a unix domain socket instead of a TCP socket (so you don't have to start the postmaster with -i)? Using a TCP...
15
by: Alpha | last post by:
I was told that Unix API can only be called using C++, ATL and MFC. However, I was also told that C# can do that through Pinvoke to a DLL that interfaces with the Unix API. Can someone direct me...
1
by: Chris | last post by:
Hi, I am using PHP persistent sockets and have a problem with them. The problem is that PHP only sends the data when the socket is closed. In the code example below the counterparty process...
223
by: Pilcrow | last post by:
Given that UNIX, including networking, is almost entirely coded in C, how come so many things are almost impossible in ordinary C? Examples: Network and internet access, access to UNIX...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...

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.