Page 1 of 2

network lib ?

Posted: Sun Mar 05, 2006 12:08 am
by doodlemunch
hi i need a net lib for tcp or udp
i need to make like 30 servers in my program i can not do this with pbs lib


no i do not have pb full i use the demo

is there any lib ?

Posted: Sun Mar 05, 2006 12:15 am
by Tranquil
The forthcomming version of PB (4.0) will support this feature due his normal command-set.

BUT if you want to code a server you will STRONGLY need the full version of PB couse you need API for your event handling.

Even a server is VERY hard to code.

Mike

Posted: Sun Mar 05, 2006 12:21 am
by USCode
Tranquil wrote:...BUT if you want to code a server you will STRONGLY need the full version of PB couse you need API for your event handling.

Even a server is VERY hard to code.
Is that true, you need to call into the native platform's API for server network event handling??? PB's Network lib doesn't handle network events for us??? Bummer, I thought it did ... :?:

Posted: Sun Mar 05, 2006 12:25 am
by dagcrack
IT DOES .. and you CAN use Windows' API calls in DEMO .. just open the dll and call by yourself, jeez lazy people..!!

Posted: Sun Mar 05, 2006 12:30 am
by Shannara
Becareful, if you need to run on more then one port/ip combo in the same program, PB4 will NOT allow you to do this. The PB network library will not allow you to do this and you would have to do use windows API until the library is completed.

Posted: Sun Mar 05, 2006 12:35 am
by Tranquil
I used PB3.xx to create multiple server instances in one process. Runs fine but you need API to do it.

How does PB Catches network events? You need to use WSAsyncSelect() to bind the sockets messages to a windows message queue.

The only way in PB for now is to "pool" network messaged. But thats not very smart on both sides: server and client.

Posted: Sun Mar 05, 2006 12:06 pm
by Fred
Of course PB handle the network event for you, and you can create any number of servers in the same program in v4. I don't see where it's 'very' hard to code, as you handle the events exactly like the window event scheme. If it doesn't work, please post a bug report which shows the problem.

Posted: Sun Mar 05, 2006 12:11 pm
by DarkDragon

Posted: Sun Mar 05, 2006 12:34 pm
by thefool
The actual server wich receives the incoming data and sends something out should be a breeze to make.

Depending on WHAT you want to do with the data, that CAN be hard.. But thats not pb's fault ;)

Posted: Sun Mar 05, 2006 5:51 pm
by Shannara
If he is talking about bounding an multiple IPs to his program, it is impossible with the PB network library. He would have to use the winsock API. Im actually waiting for his clarification reply :)

Posted: Sun Mar 05, 2006 6:37 pm
by Nik
You can bind multiple ports to one program in Pb 4.0 easily on the servesie tahts a fact, you can't specify the ip on the client side, true but I never encountered any case where this would be needed, maybe there are some rare cases with multiple network connections (card, wifi and LAn or something like that) but even there windows is verry likely to do it correct on both network adapters without a code change. And yes the event capturiong is done by pb and no I don't think it uses async sockets, but the peek flag in a blocking recv api command, as the UDP Lib did. The only real problem with the PB network lib is that its not verry efective because you have to manage all events in one thread, but this is more advanced stuff and not needed for simple purpose servers. If you don't believe me visit the Link(sorry it's german but the Download is on the frontpage) in my signature, downlaod our Messenger Client (100% PB) and test how perfectly it works together with our Server (100% PB up since 15 days, without any problem (it's also one of the Cross Platform PB programs since it compiles and works both under windows and linux)). It's true I'm currently working on replacing the Server with one written in C++ but thats only bbecause of the multithreading problems and for learning C++.

EDIT: Yes! It's hjard to write a stable server but thats not because of pbs libray limitations but because of reliability and the Design of the TCP/IP protocoll wich will split big messages in chuncks though they are garantied to come in the right order you will have to collect the data chunks until you have your complete message, file whatever and handling this can be verry tricky

Posted: Sun Mar 05, 2006 6:39 pm
by Fred
Shannara wrote:If he is talking about bounding an multiple IPs to his program, it is impossible with the PB network library. He would have to use the winsock API. Im actually waiting for his clarification reply :)
Better read his post again, he wants multiple servers, no multiple IPs. You can open any number of servers on different ports, it's not a problem.

Posted: Sun Mar 05, 2006 6:49 pm
by Shannara
Nik: Business workstations usually have multiple IP addresses bound to them :) Another instance sould be server applications.

Fred: Ah, that makes sense then :) When I read his post concerning 30 servers in his one application, I assumed he wanted server grade. Thanks for the heads up- and my re-read. I gotta read more carefully.

Posted: Sun Mar 05, 2006 6:56 pm
by Nik
Let me quote the Linux man pages, since Windows copied the Network functions it shoulw be the same:
When INADDR_ANY is specified in the bind call the socket will be bound to all local interfaces.
As PB surely uses INADDR_ANY you cann access every network interface avaible to the computer over the OpenNetworkConnection command and your servers created with CreateServer() should also be accesible form every interface availale.

Posted: Sun Mar 05, 2006 7:04 pm
by Shannara
No. That is where I disagree due to real world examples. IRC Servers should only be bound to specific IPs, same with Email Servers, FTP servers, Torrent servers, game servers, the list goes on.

The thing is, if you have server software, in most cases, it would have multiple IP addresses assigned to it. You only want software to respond to the proper IP addresses. More information can be found @ http://www.purebasic.fr/english/viewtop ... highlight=