network lib ?

Just starting out? Need help? Post your questions and find answers here.
doodlemunch
Enthusiast
Enthusiast
Posts: 237
Joined: Tue Apr 05, 2005 11:20 pm

network lib ?

Post 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 ?
my english is horribel i know - SORRY i am dyslexic - i uses pb 3.94
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post 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
Tranquil
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Post 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 ... :?:
dagcrack
Addict
Addict
Posts: 1868
Joined: Sun Mar 07, 2004 8:47 am
Location: Argentina
Contact:

Post by dagcrack »

IT DOES .. and you CAN use Windows' API calls in DEMO .. just open the dll and call by yourself, jeez lazy people..!!
! Black holes are where God divided by zero !
My little blog!
(Not for the faint hearted!)
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post 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.
Tranquil
Addict
Addict
Posts: 952
Joined: Mon Apr 28, 2003 2:22 pm
Location: Europe

Post 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.
Tranquil
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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.
DarkDragon
Addict
Addict
Posts: 2344
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Post by DarkDragon »

bye,
Daniel
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post 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 ;)
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post 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 :)
Nik
Addict
Addict
Posts: 1017
Joined: Fri May 13, 2005 11:45 pm
Location: Germany
Contact:

Post 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
Last edited by Nik on Sun Mar 05, 2006 6:41 pm, edited 1 time in total.
Fred
Administrator
Administrator
Posts: 18162
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post 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.
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post 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.
Nik
Addict
Addict
Posts: 1017
Joined: Fri May 13, 2005 11:45 pm
Location: Germany
Contact:

Post 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.
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post 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=
Post Reply