PDA

View Full Version : sockets in VC


Marcelis
01-12-2002, 03:45 PM
Incep sa studiez socket-urile in VC. Am gasit un program care se conecteaza la pop server si verifica existenta scrisorilor in cutie. Executabilul lucreaza, dar nu-l pot compila la mine, da eroare:
fatal error C1010: unexpected end of file while looking for precompiled header directive
Un program simplu:
*********************
#include <winsock.h>
int s,x;
int main() {
s = socket(AF_INET, SOCK_STREAM,0);
return 1;
}
*********************
da eroare la link-are:
main.obj : error LNK2001: unresolved external symbol _socket@12

Am nevoie de o indrumare cum sa incep "corect" a scrie un program simplu ce ar verifica cutia postala, si de ce apar erorile sus mentionate.
Merci anticipat.


<font size=-1>[ Acest mesaj a fost editat de: Marcelis pe 12-01-2002 17:03 ]</font>

Marcelis
01-12-2002, 06:04 PM
Am gasitraspuns deja.

Gluk_-
01-15-2002, 05:59 PM
Hi Marcelis !
i'll try 2 help u follow me :

in VC open your project .
on the menu where is "file", "edit" etc. select "project" and , go in and select "settings..."
"project settings" dialog box was opened ,
in the left up conner of it u'll find "settings for :" scroll box select "all configurations" , now at the right side of the "project settings" dialog box click on "C/C++" tab , within this tab find
scroll box named "category" and select within "precompiled headers" after select "not using precompiled headers" radio button and press OK == > this must resolve your first problem .

": error LNK2001: unresolved external symbol _socket@12" - was received from system because u not included the needed Ws2_32.lib file in project settings - follow me :smile: :

open "project setting" dialog box , select "all configurations" , select "link" tab at the right part of this dialog box
there u'll find edit box called "object/library modules" all u need to do is to write Ws2_32.lib file name at the end of allredy written there names of another *.lib files == > this will resolve your second problem :smile:

regards .

Bion
01-16-2002, 02:04 PM
Răspunsul corect:
1. #include "stdafx.h"
2. #pragma comment(lib,"Wsock32.lib") sau îl adaogi la Link p/n All Configurations aşa cum a lămurit Gluk_.

ambele directive le pui in cpp.
în loc de Wsock32.lib poti pune Ws2_32.lib, depinde ce versiune vrei să folosesti.

Gluk_-
01-16-2002, 03:39 PM
Bion can u explain me pls what "lămurit" is mean ?

thnx !

Marcelis
01-17-2002, 03:02 PM
2 Gluk_- thanks for your help.

2 Bion de la "game station-u meu" mersi shi tzie. (Ai inet prin game-station? sau ce?)

Bion
03-06-2002, 01:36 PM
Gluk_, lămuri(explica) == explain :smile: (so, lămurit == explained)
Marcelis, game-station == work-station :grin: (în cazul meu), am inet 24 din 24(ore).

Have a nice day, people.

2008.