Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2001-01

Server

15 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

boci

Hallo!
I want to use the TInetServer or the ssocket.
I see the example applications, but I don't understand. I can use the destroy, but If I create the server socket on a port xxx how catch the client socket?
So I want to give a socket into variable.
Somebody can help me???
Thanx.
Cow

boci

Halley!
So.
I want to write a server (associated to a port) on the basic packages. It's possible?
I see the documentation, and I found a socket library. In the documentation have an example, how to write an unix domain socket. I want to write an internet socket, but I didn't find Accept and other function, where the parameter is the port. I found only the fcl library, but I want to use a protable solution. The sscoket library doesn't work on windows system, but all system contain the socket unit. And I see, the unit constants and i found AF_INET and PF_INET socket type.
Cow.

FPC Mail list reader

Try using just the fns in sockets.pp,you have there (almost) all you need; in order to use accept() , you need to bind the socket and you can specify the port in the bind() call.

Bogdan.

Andrey Kubyshev
to boci: Halley! So. I want to write a server (associated to a port) on the basic packages. It's…

Hello boci,

boci> So.
boci> I want to write a server (associated to a port) on the basic packages. boci> It's possible?
boci> I see the documentation, and I found a socket library. In the documentation boci> have an example, how to write an unix domain socket. I want to write an boci> internet socket, but I didn't find Accept and other function, where the boci> parameter is the port. I found only the fcl library, but I want to use a yes, its possible but it will not be really "stable server" i write simplest http server .. it works good but maybe for example on 5000th thread it crashes (i use pthread coz native thread is not good for that)

Best regards, Kubyshev Andrey
Brad Campbell
to Andrey Kubyshev
Andrey Kubyshev wrote
Hello boci,

yes, its possible but it will not be really "stable server" i write

Show quoted text 6 lines
simplest http server .. it works good but maybe for example on 5000th thread it crashes (i use pthread coz native thread is not good for that) -- Best regards, Kubyshev Andrey

Having written several "Servers" used on a daily basis with FPC, I believe the problems you have are related to your use of Threads.. If you write a server based on either select() or fork() I believe you will not have this problem. Please stop telling people FPC is no good for writing servers.. You are wrong.. It may, however, be unsuitable for writing multi-threaded applications at the moment due to the non-reentrancy of the fcl.. (and rtl?) ..

Brad.... /"\ Save the Forests \ / ASCII RIBBON CAMPAIGN Burn a Greenie. X AGAINST HTML MAIL / \
FPC Mail list reader
to Brad Campbell: yes, its possible but it will not be really "stable server" i write Having written…
Having written several "Servers" used on a daily basis with FPC, I believe the problems you have are related to your use of Threads.. If you write a server based on either select() or fork() I believe you will not have this problem.

But how can you, for example, do a server which can service more than 256 connections at the same time with select() ? If i'm not wrong, the fdset type only allows checking for 256 descriptors ...

Bogdan

FPC Mail list reader
to boci: Ok, but how! Pleeeeeease, how? I want, but I didn't find documentation..... Or…
boci wrote
Ok, but how! Pleeeeeease, how? I want, but I didn't find documentation..... Or example..... Please send me, how? Thanx Cow.

try the attachment as a template; all it does is bind the socket, allow one connection, send a message, wait for one and then exit. if you want to do a server that actually works, try the serverex example( located in <ppdir>\source\docs\sockex\serverex.pp . It'll show you how to accept more connections at the same time, plus other things you need to know.

Bogdan.

Sebastian Günther
to FPC Mail list reader: But how can you, for example, do a server which can service more than 256 connections at…
FPC Mail list reader wrote
But how can you, for example, do a server which can service more than 256 connections at the same time with select() ? If i'm not wrong, the fdset type only allows checking for 256 descriptors ...

With a standard kernel, yes. But it's possible to increase this number in the kernel. IIRC there has been some talk about this in the Linux kernel mailing list some time ago...

- Sebastian

Peter Vreman
Show quoted text 10 lines
FPC Mail list reader wrote: > > But how can you, for example, do a server which can service more than 256 > connections at the same time with select() ? If i'm not wrong, the fdset > type only allows checking for 256 descriptors ... With a standard kernel, yes. But it's possible to increase this number in the kernel. IIRC there has been some talk about this in the Linux kernel mailing list some time ago...

When you strace your program under linux it always shows 'old_select'. So there should already be a new select syscall

Unknown author
to Sebastian Günther: With a standard kernel, yes. But it's possible to increase this number in the kernel.…
Show quoted text 9 lines
FPC Mail list reader wrote: > > But how can you, for example, do a server which can service more than 256 > connections at the same time with select() ? If i'm not wrong, the fdset > type only allows checking for 256 descriptors ... With a standard kernel, yes. But it's possible to increase this number in the kernel. IIRC there has been some talk about this in the Linux kernel mailing list some time ago...

Or you can use 'poll' which does the same as 'select' only it can handle an infinite amount (well, as much filedescriptors as Linux has) of file descriptors.

Michael.