Click here to Skip to main content
15,914,820 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: How to create transparent menu for Dialog? Pin
includeh1017-Apr-06 16:14
includeh1017-Apr-06 16:14 
Questionmyodbc mysql HELP! Pin
eusto17-Apr-06 7:59
eusto17-Apr-06 7:59 
AnswerRe: myodbc mysql HELP! Pin
Milton Karimbekallil17-Apr-06 11:43
Milton Karimbekallil17-Apr-06 11:43 
GeneralRe: myodbc mysql HELP! Pin
eusto17-Apr-06 20:35
eusto17-Apr-06 20:35 
GeneralRe: myodbc mysql HELP! Pin
eusto18-Apr-06 0:43
eusto18-Apr-06 0:43 
QuestionRe: Convert STL string -->TCHAR (final clairification) Pin
chasetoys17-Apr-06 7:59
chasetoys17-Apr-06 7:59 
AnswerRe: Convert STL string -->TCHAR (final clairification) Pin
Saurabh.Garg17-Apr-06 17:07
Saurabh.Garg17-Apr-06 17:07 
Question[RESOLVED]Socket function failed in dll called dynamically Pin
Fredericfr17-Apr-06 6:42
Fredericfr17-Apr-06 6:42 
Hello,

here my problem with socket:

I've got a simple program with a main that calls a dll dynamically.
Example:
int main(int argc, char *argv[])
{      	
HINSTANCE lib = LoadLibraryA("C:\\mylib.dll");
	if (lib == NULL)
		printf("LoadLibraryA failed\n");
}


As my dll has a "DllMain" function, it automatically enters in it and it executes code I want to.
My problem is I want to init socket there and whatever I do the "socket" function failed.
My code compile so I've got the good includes and i've attach the Ws2_32.lib in my dll.
Example:
<code>SOCKET m_socket;
WSADATA wsaData;
int res;

res = WSAStartup(MAKEWORD(2,2), &wsaData);
if (res != NO_ERROR)
{
	printf("Error : WSAStartup() [%ld]\n", WSAGetLastError());
	return 1;
}
m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
if (m_socket == INVALID_SOCKET)
{
	printf("Error : socket() [%ld]\n", WSAGetLastError());
	WSACleanup();
	return 1;
}
...</code>

Socket function always failed with this error code: 10091 that is in MSDN: WSASYSNOTREADY
In MSDN it is said that this error is returned by WSAStartup. However for me it is the socket function.

If I translate my socket code directly in my main program, it works pretty well. As a consequence, are there some trouble to deal with socket in a dll called dynamically?

Thanks for your help.


-- modified at 14:32 Monday 17th April, 2006
AnswerRe: Socket function failed in dll called dynamically Pin
Michael Dunn17-Apr-06 7:57
sitebuilderMichael Dunn17-Apr-06 7:57 
GeneralRe: Socket function failed in dll called dynamically Pin
Fredericfr17-Apr-06 8:32
Fredericfr17-Apr-06 8:32 
QuestionHow give the dimension to line. Pin
sataoa17-Apr-06 6:34
sataoa17-Apr-06 6:34 
QuestionDynamic arrays Pin
Waldermort17-Apr-06 6:12
Waldermort17-Apr-06 6:12 
AnswerRe: Dynamic arrays Pin
Joe Woodbury17-Apr-06 6:25
professionalJoe Woodbury17-Apr-06 6:25 
GeneralRe: Dynamic arrays Pin
Waldermort17-Apr-06 6:32
Waldermort17-Apr-06 6:32 
GeneralRe: Dynamic arrays Pin
David Crow17-Apr-06 7:17
David Crow17-Apr-06 7:17 
GeneralRe: Dynamic arrays Pin
Waldermort17-Apr-06 8:21
Waldermort17-Apr-06 8:21 
GeneralRe: Dynamic arrays Pin
Nemanja Trifunovic17-Apr-06 9:02
Nemanja Trifunovic17-Apr-06 9:02 
GeneralRe: Dynamic arrays Pin
Waldermort17-Apr-06 9:14
Waldermort17-Apr-06 9:14 
GeneralRe: Dynamic arrays Pin
Nemanja Trifunovic17-Apr-06 10:41
Nemanja Trifunovic17-Apr-06 10:41 
AnswerRe: Dynamic arrays Pin
Joe Woodbury17-Apr-06 10:29
professionalJoe Woodbury17-Apr-06 10:29 
GeneralRe: Dynamic arrays Pin
Nemanja Trifunovic17-Apr-06 10:46
Nemanja Trifunovic17-Apr-06 10:46 
GeneralRe: Dynamic arrays Pin
Joe Woodbury17-Apr-06 21:21
professionalJoe Woodbury17-Apr-06 21:21 
QuestionImpersonation and Access Rights Pin
Putta_V17-Apr-06 5:28
Putta_V17-Apr-06 5:28 
QuestionLinker Error ?? Pin
jinbabaj17-Apr-06 5:03
jinbabaj17-Apr-06 5:03 
AnswerRe: Linker Error ?? Pin
David Crow17-Apr-06 5:11
David Crow17-Apr-06 5:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.