|
Hi all,
i have one problem related to thread. i am having my main thread running which will
on some event create a thread for validation purpose and then will start working.
and now this validator thread will create a socket and it will bind to port 20111.
and then will wait for client to connect.
but before waiting for client to connect it will send a message to the main thread that
validation is done.
but in this way i need to stick with port 20111.which i really don't want.
Is it possible for me to get a free port from operating system or from winsock
library and then i should bind to this port??
and one more thing i want is i want to get the free port no that operating system
has given in an variable because i will need that port number further in the main programs lifetime.
the code is as follows
UINT Thread_Func(LPVOID pParam)
{
wsaret = WSAStartup(0x101,&wsadata);
if(wsaret != 0)
return -1;
sock.sin_family = AF_INET;
sock.sin_addr.s_addr = INADDR_ANY;
sock.sin_port = htons((unsigned short)20111);// iwant to obtain this port no on fly and
// to get it in some variable so that i can use it further in my main thread
server = socket(AF_INET,SOCK_STREAM,0);
if(server == INVALID_SOCKET)
return -1;
if(bind(server,(SOCKADDR *)&sock,sizeof(sock))!=0)
return -1;
if(listen(server,1)!=0)
return -1;
cli_len = sizeof(cli);
client = accept(server,(SOCKADDR *)&cli,&cli_len);
if(client == 0)
return -1;
return 1;
}
i have not done socket programming before this is my first time i am doing it
so if there are any mistakes please let me know
Thanks and regards
Harshal shete
|
|
|
|
|
something in the back of my brain said: "sock.sin_port = 0" would let the OS select the port....
|
|
|
|
|
yes that is true but how i can access that port number??
|
|
|
|
|
maybe you can reverse use the sock.sin_port after the connection has been occured with
port = ntohs(sock.sin_port) from the socket.
|
|
|
|
|
I want to write a program that makes MS-Word open a doc file, make some changes to it and then save it.
I don't want to open the entire word GUI every time I do this, how can I interface with Word in such a way?
|
|
|
|
|
You have to look for "Word automation"
|
|
|
|
|
how can i edit records ?
i now can i addNew ! but to edit records is hard ! i have this errror : "SQL : Statement too long" what is that meaning of this !?what can i do ? the sql odbc driver is not good !
my class is working wyth odbc -> database !
i have CDialog base application 1 CEdit and i whant to edit a field in to my table! can someoane give me an example ?
Bravoone
|
|
|
|
|
How do you want to do it?
Through a direct query (SQL "UPDATE") or through a recordset?
Do you have the text from the edit control?
What have you tried?
Bravoone_2006 wrote: the sql odbc driver is not good !
HUH?
|
|
|
|
|
Hadi Dayvary wrote: Re: Run an URL
ShellExecute(NULL,"open","http://www.codeproject.com",NULL,NULL,SW_SHOW);
This line would open a browser window with the URL. See if this is what you need or you would have to provide some more details.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Where is question?
|
|
|
|
|
I think the question was deleted after I answered his query.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
_AnShUmAn_ wrote: I think the question was deleted after I answered his query
one more stupid selfish... lol
|
|
|
|
|
toxcct wrote: one more stupid selfish... lol
he he he
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and you
|
|
|
|
|
What puzzles me is the 1 vote given to WhiteSky for asking where the qustion was. I am unable to understand what is the motivation for people to vote (No matter if the vote is 1 or anything else)
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
brahmma wrote:
understand what is the motivation for people to vote (No matter if the vote is 1 or anything else)
no problem my Vote 5 square that off
<div class='ForumSig'>"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers, Alok Gupta VC Forum Q&A :- I/ IV Support CRY- Child Relief and you </div>
|
|
|
|
|
i think the voter thought that WhiteSky could figure out by himself that the question was deleted...
voter, if you're there, show off !
|
|
|
|
|
But I'm wonderful two weeks ago some my answers has 1 vote and if I have a answer with vote 5 sudden after several time it was 3
|
|
|
|
|
I dont know (and its a question for me)why some people delete their questions maybe they think that their questions are simple but its not true.
|
|
|
|
|
toxcct wrote: one more stupid selfish... lol
May be he thought that's the protocol i.e. When your question is answered delete it.;)
|
|
|
|
|
that's selfish anyway, because forums are not chat rooms, and their purpose are to share knowledges...
an answer worthes nothing without its question...!
|
|
|
|
|
can any body help me for invoking bios service in vc++
vimal
|
|
|
|
|
Read this[^]. Be more specific.
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
You can't. In general the BIOS is only used by Windows during the boot process. Once Windows is up and running device drivers do the jobs for which you'd use direct BIOS calls in DOS applications. When Windows runs old DOS applications using WOW the BIOS calls are intercepted and redirected through device drivers. Windows is a multitasking OS and in such an environment you can't have applications making direct BIOS calls.
Steve
|
|
|
|
|
Hi, currently I'm doing a program that needs to load data packets under HTTP and telnet protocol intercepted and stored in a database, then display the data interpreted. I wonder if there are some existing control/component or something that can do the HTTP/telnet protocol interpretation in VC++? Thanks a lot!
|
|
|
|
|
I want to differnetiate Group A and B due to certain conditions in a listcontrol. Can i use SelectItem()?
How can i do it?
|
|
|
|