Sign in Join

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

Mailing lists / fpc-pascal / 2001-01

Thread + Inet

6 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

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

boci

Halley,
I have a little problem. I want to write a multithreaded server. So I create a server socket (So I try, but I not found some documentation), after I wait the client connection (in an unlimited cycle), and I create a new thread (next problem: How I create a new thread without array (I don't want controlling), (Example in java, I create a class from the Thread class and I create a dynamic thread (new thread(parameter))), so I give the socket to the thread (I think I use the constructor), and wait the nex connection (Don't need clear the socket variables, before I waiting the next client?)
Thanx.
Cow from Hu

Reply by email

Peter Vreman
to boci
Show quoted text 9 lines
I have a little problem. I want to write a multithreaded server. So I create a server socket (So I try, but I not found some documentation), after I wait the client connection (in an unlimited cycle), and I create a new thread (next problem: How I create a new thread without array (I don't want controlling), (Example in java, I create a class from the Thread class and I create a dynamic thread (new thread(parameter))), so I give the socket to the thread (I think I use the constructor), and wait the nex connection (Don't need clear the socket variables, before I waiting the next client?)

There is a very basic implementation of the TThread class available in the FCL. Maybe it's enough for your program to run the socket functions with. But be carefull with other things as the RTL itself isn't multithreaded aware yet.

Peter

Reply by email

Andrey Kubyshev
to boci: I have a little problem. I want to write a multithreaded server. So I create a server…

Hello boci,

Wednesday, January 03, 2001, 9:53:11 PM, you wrote:

boci> Halley,
boci> I have a little problem. I want to write a multithreaded server. boci> So I create a server socket (So I try, but I not found some boci> documentation), after I wait the client connection (in an unlimited boci> cycle), and I create a new thread (next problem: How I create a new thread boci> without array (I don't want controlling), (Example in java, I create a I think you cannot write stable multithreaded server for linux platform with current version of FPC. I spend a lot of time on it but it crashes sometimes anyway. I even used c memory manager and pthread library.

Best regards, Kubyshev Andrey

Reply by email

Marco van de Voort
to Peter Vreman: There is a very basic implementation of the TThread class available in the FCL. Maybe…
Show quoted text 15 lines
>I have a little problem. I want to write a multithreaded server. >So I create a server socket (So I try, but I not found some >documentation), after I wait the client connection (in an unlimited >cycle), and I create a new thread (next problem: How I create a new thread >without array (I don't want controlling), (Example in java, I create a >class from the Thread class and I create a dynamic thread (new >thread(parameter))), so I give the socket to the thread (I think I use the >constructor), and wait the nex connection (Don't need clear the socket >variables, before I waiting the next client?) There is a very basic implementation of the TThread class available in the FCL. Maybe it's enough for your program to run the socket functions with. But be carefull with other things as the RTL itself isn't multithreaded aware yet.

And neither are syscalls. So even if you try to use the unit Unix/Linux directly, it won't work.

Reply by email

Roderick van Domburg
to Marco van de Voort
Show quoted text 8 lines
> --[cut]-- > There is a very basic implementation of the TThread class available in the > FCL. Maybe it's enough for your program to run the socket functions with. > But be carefull with other things as the RTL itself isn't multithreaded > aware yet. And neither are syscalls. So even if you try to use the unit Unix/Linux directly, it won't work.

Just a brainwave -- how about forking and using interprocess signals? I guess you couldn't send a lot of data back and forth between the instances, so you would need to come up with a way to publish addresses to unprotected memory areas. Too far fetched?

Reply by email

Marco van de Voort
to Roderick van Domburg
Show quoted text 13 lines
> > --[cut]-- > > There is a very basic implementation of the TThread class available in the > > FCL. Maybe it's enough for your program to run the socket functions with. > > But be carefull with other things as the RTL itself isn't multithreaded > > aware yet. > > And neither are syscalls. So even if you try to use the unit Unix/Linux > directly, it won't work. Just a brainwave -- how about forking and using interprocess signals? I guess you couldn't send a lot of data back and forth between the instances, so you would need to come up with a way to publish addresses to unprotected memory areas. Too far fetched?

Yes. I think the language helpers are the biggest problem. Ordinary functions at least, you can protect with mutexes.

Reply by email