473,396 Members | 2,061 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,396 software developers and data experts.

writing to a socket with data from struct

I am trying to write a small program that sends some data over the
network to a server. The data I want to send is read from the command
line i.e. dms 2 somedata otherdata value hostname port. I have the
client talking to the server. The problem I am having sending the
command data to the server. CreateDSM creates the network connection
to the server. This is what I am doing:

int A, B,dsm1, dsm2;
struct fullpacket {
int requesttype;
char varname;
int vartype;
char varval;
} packet;

main(int argc, char *argv[])
{
dsm1=CreateDSM(argv[5], argv[6]);
newVar(dsm1, argv[2], argv[3], argv[4]);
exit(0);
}

int newVar(const char *varname, const char *vartype, const char
*initialvalue)
{ packet.requesttype=1;
packet.varname=*varname;
packet.vartype=*vartype;
packet.varval=*initialvalue;
(void) write(dsm1, packet, sizeof(packet));
}
As you can see I am trying to write a struct to a socket. When I
compile I get the following message: incompatible type for argument 2
of 'write'. How can I fix it or get around this problem?

Thanks,
Mike

Apr 14 '06 #1
1 2962
bo******@hotmail.com wrote:

int A, B,dsm1, dsm2;
struct fullpacket {
int requesttype;
char varname;
int vartype;
char varval;
} packet; (void) write(dsm1, packet, sizeof(packet));
}
As you can see I am trying to write a struct to a socket. When I
compile I get the following message: incompatible type for argument 2
of 'write'. How can I fix it or get around this problem?

There is no write() function in standard C, the topic of this
newsgroup.

<OT>

write() usually takes a pointer for the second argument, you are
passing a struct. Possibly you wanted

write(dsm1, &packet, . . . )

</OT>
Further questions should directed to a platform-specific newsgroup.


Brian
Apr 14 '06 #2

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

Similar topics

4
by: chellappa | last post by:
Hi, This is program for socket program for server and client ... but data send from client and receive by server but i can t sen d message fro m server to client ... check i mistake .. i treed...
6
by: Abubakar | last post by:
Hi, lets say I have a connected SOCKET s. At some point in time, I want to know if the "s" is still valid, that it is still connected. Is there any API that I can give me this information? And...
5
by: Tiger | last post by:
Hi, I try to send a packet with raw socket but I have an error with ethereal sniffer on windows xp. I can't find any solution on the net. :( Could anybody help with that problem? my code :...
1
by: xoinki | last post by:
hi experts, I need a little help in debugging this code.. would u pleeze kindly help me? here this program sends a datagram every 10 seconds and on reception it cheks whether the source IP is...
6
by: Sean | last post by:
Hi Everyone, My apologies for a somewhat dump question but I am really stuck. I have been working on this code for two days straight I am dont know what is wrong with it. when I run the code, All...
2
by: apollo135 | last post by:
Dear All, Could someone help and tell me how to handle multiple send and receive operations with udp sockets? In fact here is my problem: server.c is composing of serveral sub programs (the...
1
by: Clement | last post by:
Please tell me why the follwing program is not working............ client.c #include<stdio.h> #include<sys/socket.h> #include<sys/un.h> int main() {
1
by: samuelsam | last post by:
My project must send data from server to client via socket which implement by tcp socket.Now it is working but there is a one big problem that when the server program end , I must run the server...
4
by: shailesh333 | last post by:
#include <stdio.h> #include <string.h> #include <unistd.h> #include <sys/types.h> #include <Winsock2.h> #include <stdlib.h> #define PORTNUM 2343 int main(int argc, char *argv)
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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.