writing to a socket with data from struct

B

bofh1234

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
 
D

Default User

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,241
Latest member
Lisa1997

Latest Threads

Top