Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Socketprogramming

Status
Not open for further replies.

mattias1975

Programmer
Joined
Jul 26, 2004
Messages
36
Location
SE
#include <winsock2.h>
#include <wininet.h>
#include <stdio.h>
#include <conio.h>
#include <iostream.h>

void main(){
int sock = socket (PF_INET, SOCK_RAW, IPPROTO_TCP);
cout << sock;
}

But the socket function returns the value -1 which i know is an error code. I think it should return 1 if it is ok.
Why does not this work? Why do i get the error code -1?
 
Every windows sockets program begins with a call to WSAStartup

Oh, and main returns an int, not void.

--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top