|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
A question about sockets, listenerI am working on a Windows service application that will listen on multiple IPs and ports e.g. port 25, 110 etc. As far as I could see the EndPoint only contains one IP and a port. How is it possible to listen on multiple IPs and multiple ports of an IP? Would there be separate socket for each combination of IP and ports?
Also, what is the best way for coding a listener -- an indefinite loop, or there could be any other better way to do this? Thanks in advance. look in the help on the Socket object. theres a listen method you can use
that will tell you when a connection attempt has been made. then read up on the async ways to use a socket. its not too difficult. microsoft made sockets very east to use with AddressOf and using it in sockets. if you need an example, just email me at jmmgoalster at yahoo dot com and i can send you a socket example using TCP sockets -- -iwdu15 Thanks for the hint. I have seen the example and it uses an indefinite loop
to keep listening which could be quite resource-intensive. In some examples I have seen timer is used for listening on small intervals. That too has some shortcomings. Tips for any other ideas or work arounds will be much appreciated. Show quoteHide quote "iwdu15" <jmmgoalsteratyahoodotcom> wrote in message news:EF3FD8AE-BFB7-4181-95E7-5CBB8E3D2D9B@microsoft.com... > look in the help on the Socket object. theres a listen method you can use > that will tell you when a connection attempt has been made. then read up > on > the async ways to use a socket. its not too difficult. microsoft made > sockets > very east to use with AddressOf and using it in sockets. if you need an > example, just email me at jmmgoalster at yahoo dot com and i can send you > a > socket example using TCP sockets > -- > -iwdu15 im not sure what code uve seen that uses an infinite loop for listening...ive
created one where you dont need a loop, it listens for you without looping, you just call mysocket.Listen(50) email me and il send you my example, jmmgoalster at yahoo dot com -- -iwdu15 at low level
you wil always need a loop to listen for data to arrive This is just how it works and i do not see the problem regards Michel Posseth [MCP] Show quoteHide quote "iwdu15" wrote: > im not sure what code uve seen that uses an infinite loop for listening...ive > created one where you dont need a loop, it listens for you without looping, > you just call > > mysocket.Listen(50) > > email me and il send you my example, jmmgoalster at yahoo dot com > -- > -iwdu15 this is tru, i appologize if i made it seem like i was saying that you never
needed to use looping. i took it as he was trying dim boolStop as Boolean = False do Socket1.Listen() while boolStop <> True thats what i took it as...maybe i was wrong....i appologize -- -iwdu15 |
|||||||||||||||||||||||