fastnet5
asked on
Issue with Data Recv in Socket programming
Hi,
I am working on a client Application using a socket.I am getting the problem while receiving the data.The recv return value is not matching with the no of character received.For Ex
typedef struct {
unsigned short len;
unsigned long ref;
unsigned char data[65529];
} DATA_PCKT;
numBytes = recv(socketId, (char *)&recvPckt, sizeof(recvPckt),MSG_PEEK) ;
here numbytes return 77
dataLen = ntohs(recvPckt.len) - DatapcktHdrSz; = 71
int ii=strlen((char*)recvPckt. data); = 69.
It is triming first two charater.I don't know why ?
Please help
I am working on a client Application using a socket.I am getting the problem while receiving the data.The recv return value is not matching with the no of character received.For Ex
typedef struct {
unsigned short len;
unsigned long ref;
unsigned char data[65529];
} DATA_PCKT;
numBytes = recv(socketId, (char *)&recvPckt, sizeof(recvPckt),MSG_PEEK)
here numbytes return 77
dataLen = ntohs(recvPckt.len) - DatapcktHdrSz; = 71
int ii=strlen((char*)recvPckt.
It is triming first two charater.I don't know why ?
Please help
send func :
DATA_PCKT sendData;
DatapcktHdrSz = sizeof(sendData.len) + sizeof(sendData.ref);
memcpy(&sendData.data, message.c_str(), message.size());
sendData.len = htons(message.size() + DatapcktHdrSz);
sendData.ref = htonl((rand()*100000) + 2000);
numBytes =send(socketId, (char *)&sendData, ntohs(sendData.len), 0)==-1
recv function:
numBytes = recv(socketId, (char *)&recvPckt, sizeof(recvPckt),MSG_PEEK);
dataLen = ntohs(recvPckt.len) - DatapcktHdrSz;
memcpy(message, &recvPckt.data, dataLen);
int ii=strlen((char*)recvPckt.data);
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You created a DLL that does not need to be registered. That RegSvr32 procedure you've read about is used after you create COM objects, ActiveX controls and so forth. I'd say more, but that is a completely different question and we're supposed to answer only one question at a time. And anyway, a grade of "B" is not a great compliment...
ASKER
I have one more query if you can help please.
I created a MFC Regular DLL(Dynamically Linked with MFC) .Now I have to register that DLL .When I tried to Register through command prompt using regsvr32 i got error.
untitled.bmp