Thread View: comp.os.ms-windows.programmer.win32
6 messages
6 total messages
Started by Gavin Williams
Sun, 14 Jan 1996 06:54
Sockets don't work under VC++ 4.0 ?!!
Author: Gavin Williams
Date: Sun, 14 Jan 1996 06:54
Date: Sun, 14 Jan 1996 06:54
37 lines
1773 bytes
1773 bytes
I finally got around to doing a little Windows Sockets programming in VC++
4.0 today and was quickly greeted with an ugly problem--I can't get it to
create a socket.
The CSocket::Create() function consistently failed, and
CSocket::GetLastError() returned WSAEPROTOTYPE. I tried running the CHATTER
sample program, and its socket creation failed with the same error.
Then I tried tried straight socket API calls (as opposed to using the CSocket
or CAsyncSocket classes). The "socket" function also failed with the
WSAEPROTOTYPE error.
Finally, I tried some simple sockets code in VC++ 1.52c and VC++ 2.2. The
code *worked* in both cases. The *exact same code* works fine when compiled
with 2.2 but fails when compiled with 4.0.
Here's a sample of my test code:
WSADATA wsadata;
WSAStartup( 0x0101, &wsadata );
SOCKET sock;
if( INVALID_SOCKET == (sock = socket( PF_INET, SOCK_STREAM, 0 )) )
{
int i = WSAGetLastError();
}
WSACleanup();
Two other tidbits: I'm running NT 3.51, and Microsoft's knowledge base
contained nothing about this problem.
Has anyone else out there encountered this problem? Is anyone using sockets
successfully with VC++ 4.0?
Gavin Williams
gavin@metronet.com
Re: Sockets don't work under VC++ 4.0 ?!!
Author: Derek Taylor
Date: Mon, 15 Jan 1996 19:16
Date: Mon, 15 Jan 1996 19:16
11 lines
993 bytes
993 bytes
> The CSocket::Create() function consistently failed, and > CSocket::GetLastError() returned WSAEPROTOTYPE. I tried running the CHATTER > sample program, and its socket creation failed with the same error. I've been able to compile and run CHATTER and CHATSRV just fine with 4.0 (Local LAN). ----------------------------------------------------------- Derek W. Taylor Software Engineer Edmark Corporation -----------------------------------------------------------
Re: Sockets don't work under VC++ 4.0 ?!!
Author: Brad Wilson
Date: Tue, 16 Jan 1996 01:22
Date: Tue, 16 Jan 1996 01:22
24 lines
1391 bytes
1391 bytes
Gavin Williams <gavin@metronet.com> wrote:
>> I finally got around to doing a little Windows Sockets programming in VC++
>> 4.0 today and was quickly greeted with an ugly problem--I can't get it to
>> create a socket.
>> The CSocket::Create() function consistently failed, and
>> CSocket::GetLastError() returned WSAEPROTOTYPE. I tried running the CHATTER
>> sample program, and its socket creation failed with the same error.
Do you have TCP/IP installed on the machine?
Brad
--
class CBradWilson : public CWorldWatchProgrammingTeam {
public:
CString GetInetAddr() { return CString("bradw@exptech.com"); }
CString GetPhone() { return CString("+1 (810) 620-9803"); }
CString GetURL() { return CString("http://www.exptech.com"); }
CString GetDisclaimer() { return CString("All I say is fact :-p"); }
};
// QOTW: "There is no right or wrong ... just popular opinion"
Re: Sockets don't work under VC++ 4.0 ?!!
Author: Tom Brown
Date: Tue, 16 Jan 1996 17:31
Date: Tue, 16 Jan 1996 17:31
63 lines
2759 bytes
2759 bytes
In Article<30F8A8B9.279B@metronet.com>, <gavin@metronet.com> writes:
> I finally got around to doing a little Windows Sockets programming in VC++
> 4.0 today and was quickly greeted with an ugly problem--I can't get it to
> create a socket.
>
> The CSocket::Create() function consistently failed, and
> CSocket::GetLastError() returned WSAEPROTOTYPE. I tried running the CHATTER
> sample program, and its socket creation failed with the same error.
>
> Then I tried tried straight socket API calls (as opposed to using the
CSocket
> or CAsyncSocket classes). The "socket" function also failed with the
> WSAEPROTOTYPE error.
>
> Finally, I tried some simple sockets code in VC++ 1.52c and VC++ 2.2. The
> code *worked* in both cases. The *exact same code* works fine when compiled
> with 2.2 but fails when compiled with 4.0.
>
> Here's a sample of my test code:
>
> WSADATA wsadata;
> WSAStartup( 0x0101, &wsadata );
>
> SOCKET sock;
> if( INVALID_SOCKET == (sock = socket( PF_INET, SOCK_STREAM, 0 )) )
> {
> int i = WSAGetLastError();
> }
>
> WSACleanup();
Hmmm... strange!
First of all, test the return value from WSAStartup, make sure it is
succeeding!
If so then try this socket call:
sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
...
This shouldn't be substantially different from your call, it is just more
explicit. Some points:
- The first parameter to socket() specifies an address family, not a
protocol family so the use of the AF_ constants is more appropriate.
The header file defines the PF_ and AF_ values to be the same, but
you never know...
- Specifying a specific protocol (TCP in this case) leaves the socket
library no leeway to misinterpret the kind of socket you want.
Other than this I do not know what could be wrong. A WSAEPROTOTYPE error
indicates (according to the spec) that the SOCK_STREAM parameter is not
available for a PF_INET (AF_INET) address family socket which clearly does not
make sense.
I have not tried to use 4.0 to build socket apps yet so cannot tell you that
it absolutely works.
-- Tom
twb@netmanage.com
Re: Sockets don't work under VC++ 4.0 ?!!
Author: Chris Marriott
Date: Tue, 16 Jan 1996 18:51
Date: Tue, 16 Jan 1996 18:51
18 lines
1398 bytes
1398 bytes
In article <30F8A8B9.279B@metronet.com>
gavin@metronet.com "Gavin Williams" writes:
>Has anyone else out there encountered this problem? Is anyone using sockets
>successfully with VC++ 4.0?
At work we write a large "distributed application" development toolkit
which does all its RPC calls with TCP/IP. The NT version of it ported from
VC++ 2 to VC++ 4 with no problems whatsoever - it all works fine.
Chris
--
--------------------------------------------------------------------------
Chris Marriott, Warrington, UK | Author of SkyMap v3 award-winning
chris@chrism.demon.co.uk | shareware Win31/Win95 planetarium.
For full info, see http://www.execpc.com/~skymap
Author member of Association of Shareware Professionals (ASP)
--------------------------------------------------------------------------
Re: Sockets don't work under VC++ 4.0 ?!!
Author: JR Ellis
Date: Tue, 30 Jan 1996 08:50
Date: Tue, 30 Jan 1996 08:50
31 lines
1838 bytes
1838 bytes
I have compiled the vc4 versions of chatter and chatsrv, and they work
fine on my machine. I want to make some modifications so that they
would become more useful, but I can't figure it out, and was hoping
you could help me. I have stepped through the code and still can't
find the instructions or statements that I need.
I want to redirect the pipe output on the client machine, and can't
find where or when the packets are received.
And I want to transmit other info into the pipe, and I can't find
where this is being done.
I know these are lame questions, but any help would really be
appreciated.
thank you
jr
ps-can this be modified to work over the internet?I tried using the
server ip as an internet address, and it couldn't find it.
Derek Taylor <derekt@edmark.com> wrote:
>> The CSocket::Create() function consistently failed, and
>> CSocket::GetLastError() returned WSAEPROTOTYPE. I tried running the CHATTER
>> sample program, and its socket creation failed with the same error.
>
>I've been able to compile and run CHATTER and CHATSRV just fine
>with 4.0 (Local LAN).
--------------------------------------------------------
Find betaman on irc #rawtimes or check out
Raw Fooders at http://speed.nimh.nih.gov/rawtimes.html
My personal web page at http://www.he.net/~jrellis
jrellis@rawtimes.com
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads