error compiling with read function

S

Shlomy Shivek

Hi,
I have this thread function:
//handle one socket connection thread
DWORD WINAPI SocketHandler(LPVOID lpvParam)
{
int socketNumber=*(DWORD*)lpvParam ; //the socket number
int n;
char end_connection[]={"$Exit$\n"}; //end connection message
char buffer[BUFSIZE];

n = read(socketNumber,buffer,BUFSIZE);
if (n < 0) //error reading
exit(1); //exit thread

while(strcmp(buffer,end_connection)) //until end connection has
reached
Message* x=new Message(buffer);

return 0;
}

for some reason I get the following error :
error C3861: 'read': identifier not found, even with argument-dependent
lookup

this happens using vs.net 2003 enviroment for win32 console
application.
I have the following declerations at the top of the file:
#include <iostream>
#include <winsock.h>
#include <windows.h>
#include "Message.h"
#include "MessageQueue.h"

using namespace std;
#pragma comment(lib, "ws2_32.lib")



Any idea what the problem might be ?
 
M

mlimber

Shlomy said:
Hi,
I have this thread function:
//handle one socket connection thread
DWORD WINAPI SocketHandler(LPVOID lpvParam)
{
int socketNumber=*(DWORD*)lpvParam ; //the socket number
int n;
char end_connection[]={"$Exit$\n"}; //end connection message
char buffer[BUFSIZE];

n = read(socketNumber,buffer,BUFSIZE);
if (n < 0) //error reading
exit(1); //exit thread

while(strcmp(buffer,end_connection)) //until end connection has
reached
Message* x=new Message(buffer);

return 0;
}

for some reason I get the following error :
error C3861: 'read': identifier not found, even with argument-dependent
lookup

this happens using vs.net 2003 enviroment for win32 console
application.
I have the following declerations at the top of the file:
#include <iostream>
#include <winsock.h>
#include <windows.h>
#include "Message.h"
#include "MessageQueue.h"

using namespace std;
#pragma comment(lib, "ws2_32.lib")



Any idea what the problem might be ?

This question is off-topic here since it doesn't deal with the standard
language or libraries proper. See the FAQ for what is on-topic and for
some suggestions of better places to post:

http://www.parashift.com/c++-faq-lite/how-to-post.html#faq-5.9

Cheers! --M
 
B

Ben Pope

Shlomy said:
Hi,
I have this thread function:
//handle one socket connection thread
DWORD WINAPI SocketHandler(LPVOID lpvParam)
{
int socketNumber=*(DWORD*)lpvParam ; //the socket number
int n;
char end_connection[]={"$Exit$\n"}; //end connection message
char buffer[BUFSIZE];

n = read(socketNumber,buffer,BUFSIZE);
if (n < 0) //error reading
exit(1); //exit thread

while(strcmp(buffer,end_connection)) //until end connection has
reached
Message* x=new Message(buffer);

return 0;
}

for some reason I get the following error :
error C3861: 'read': identifier not found, even with argument-dependent
lookup

Any idea what the problem might be ?

Well, all I can tell you is the same as the compiler.

read is not declared.

Read the API for your library, or ask in a more appropriate place.
Presumably you have the wrong argument types, or have not included the
correct header.

Ben Pope
 
J

Jim Langston

Shlomy Shivek said:
Hi,
I have this thread function:
//handle one socket connection thread
DWORD WINAPI SocketHandler(LPVOID lpvParam)
{
int socketNumber=*(DWORD*)lpvParam ; //the socket number
int n;
char end_connection[]={"$Exit$\n"}; //end connection message
char buffer[BUFSIZE];

n = read(socketNumber,buffer,BUFSIZE);
if (n < 0) //error reading
exit(1); //exit thread

while(strcmp(buffer,end_connection)) //until end connection has
reached
Message* x=new Message(buffer);

return 0;
}

for some reason I get the following error :
error C3861: 'read': identifier not found, even with argument-dependent
lookup

this happens using vs.net 2003 enviroment for win32 console
application.
I have the following declerations at the top of the file:
#include <iostream>
#include <winsock.h>
#include <windows.h>
#include "Message.h"
#include "MessageQueue.h"

using namespace std;
#pragma comment(lib, "ws2_32.lib")



Any idea what the problem might be ?

I beleive you want recv, not read.
 

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,773
Messages
2,569,594
Members
45,121
Latest member
LowellMcGu
Top