Computing.Net > Forums > Programming > Sockets under C++

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Sockets under C++

Reply to Message Icon

Name: tl1_mossman2
Date: January 5, 2005 at 17:35:18 Pacific
OS: Windows XP Pro
CPU/Ram: 2.0GHzcel/512MB Ram
Comment:

For those that are willing to help.

I'm attempting to write a program in C++, and I have all the elements planned, but have one problem.

The program needs to make use of Sockets. Can anyone offer some help? Direct code would be nice, though a clear tutorial would usefull as well.

(if ye choose the first, constructor taking a String host, and int port, with some appropriate method of send/receive, and closing)

Thanks



Sponsored Link
Ads by Google

Response Number 1
Name: mossman2
Date: January 5, 2005 at 22:36:51 Pacific
Reply:

slight update

using src code found here, converted to appropriate C++ code (int main, and #include <winsock2.h>

http://msdn.microsoft.com/library/en-us/winsock/winsock/complete_client_code.asp?frame=true


I've a problem in that, when attempting to compile with MinGW (if you can specify a better free compiler, I'll take it), I get about 10 errors, undefined references to various methods.

any suggestions on what might be wrong? Some how seems similar to problems I've had with namespaces before, but, can't find any references to it. Any help y'all?


0

Response Number 2
Name: bamakhrama
Date: January 6, 2005 at 01:27:49 Pacific
Reply:

Hi,
To be able to use that header file <winsock2.h> you need to import the library and put it in your work directory. The library name is WSOCK32.LIB (that is under MS VC++ 6.0). After you add that library, you should be able able to compile it without errors. To get the library, you need to look in the LIB directory in your complier folder. In MS VC++ 6.0 I found it in C:\Program Files\Microsoft Visual Studio\VC98\Lib. For MinGW, I think you should refer to manual or contact me so I send you the library by email.

--
mohameda@ieee.org


0

Response Number 3
Name: grymse
Date: January 10, 2005 at 01:14:19 Pacific
Reply:

Check out this library
http://www.alhem.net/Sockets/

Works for both unix and windows.



0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Sockets under C++

How find an SSL socket in C++ www.computing.net/answers/programming/how-find-an-ssl-socket-in-c-/3842.html

Declairation Of Socket In C www.computing.net/answers/programming/declairation-of-socket-in-c/2683.html

Interrupting Socket::Connect C++ www.computing.net/answers/programming/interrupting-socketconnect-c/14267.html