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

Difficulty with write() [Linux] and recv() [Windows]

I have a client socket connection (Linux) and a server socket connection
(Windows). All is fine with the sockets themselves.

The client-side is sending data (struct) to the server via write().
write(sockfd, &struct, sizeof(struct))

The server is receiving data via recv().
recv(clientfd, buf, sizeof(struct), 0)

Once data is received by the server, various verification checks are
performed via a 3rd-part app and the additional data is sent back to the
client, who writes the new data to a file.

I have been attempting to read the data being received, which is defined as
a char array ( char buf[sizeof(buf)]. Try as I might, I cannot seem to parse
this incoming data in any way as a string -- or struct, for that matter.

What am I doing wrong? Please!!!

I would gladly use the same socket functions as I have on Linux, but
read()/write() do not seem to be available in Windows. Or, at least I cannot
find them.

Please help me in resolving how I might convert this incoming stream of data
into structure elements.
Oct 10 '07 #1
1 1720
Dennis wrote:
I have a client socket connection (Linux) and a server socket connection
(Windows). All is fine with the sockets themselves.

The client-side is sending data (struct) to the server via write().
write(sockfd, &struct, sizeof(struct))

The server is receiving data via recv().
recv(clientfd, buf, sizeof(struct), 0)

Once data is received by the server, various verification checks are
performed via a 3rd-part app and the additional data is sent back to the
client, who writes the new data to a file.
So, things works as expected on the server? But you can not parse the
response on the client?
I have been attempting to read the data being received, which is defined
as a char array ( char buf[sizeof(buf)]. Try as I might, I cannot seem to
parse this incoming data in any way as a string -- or struct, for that
matter.
It would help to see a snippet of the code you use to write to the stream on
the server side.

Regards,

Mads

--
Med venlig hilsen/Regards

Systemudvikler/Systemsdeveloper cand.scient.dat, Ph.d., Mads Bondo
Dydensborg
Dansk BiblioteksCenter A/S, Tempovej 7-11, 2750 Ballerup, Tlf. +45 44 86 77
34
Oct 11 '07 #2

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

Similar topics

1
by: Jason | last post by:
Hi, When using the socket module in Python 2.3 for windows, I'm having problems using socket.recv(int). The function works fine on its own, but when I attempt to encapsulate the socket...
5
by: daniel.shaya | last post by:
I'll try and keep this brief so in a nutshell: I have large distributed java system running on a Windows 2003 server (4cpu 8Gb memory). Periodically the following exceptions occurs in the...
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...
6
by: Tom | last post by:
I try to write a simple tcp based job queue server. It's purpose is to get commands from a client and store them in a queue (STL). The server has a thread which checks periodically the queue,...
1
by: BilMuh | last post by:
Hello Developpers, I am developping a TCP/IP Client application using Visual C++ .NET Standard on Windows 2000 Pro. I noticed that I could not receive more than 2KB once at a time. The server...
5
by: sonu | last post by:
Hi, I m trying to receive a message on windows sockets using recv() function. The message is such that the first two bytes of the message represent the length of the message. Hence when trying...
1
by: chsalvia | last post by:
I'm try to use poll() to handle network connections on Linux. As a test, I create a simple loop that polls a socket so that everytime the client sends data, the server responds. My problem is...
10
by: Hendrik van Rooyen | last post by:
While doing a netstring implementation I noticed that if you build a record up using socket's recv(1), then when you close the remote end down, the recv(1) hangs, despite having a short time out...
1
by: raghupise | last post by:
Hi Friends, In socket programming I want to send double byte charcters. Earlier we used recv() function for single byte charcter. If we use double byte chracter in below recv function, its...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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,...
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...
0
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...

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.