Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Основная";
Текущий архив: 2004.01.09;
Скачать: [xml.tar.bz2];

Вниз

Потоки и соккеты   Найти похожие ветки 

 
Dmitriy_R   (2003-12-22 12:57) [0]

Народ подскажите кто знает, Лучше примером.
Как организовать работу соккета в виде отдельных потоков.
К примеру надо запустить серверный сокет на прослушивание, при коннекте к нему надо создать поток и в нем работать с клиентом до его отключения. Тоесть каждый клиент имеет свой отдельный поток.
В потоке для примера надо при подключении клиента отправит ему текст "Привет", при получении от клиента текста "Привет" отправить ему текст "Пока", при получении от клиента текста пока завершить соединение.
Это все написано для того чтобы лучше понять принцип работы соккетного соединения в потоке.
Если кому не трудно накидайте примерчик исходника, так проще понять. Заранее спасибо.


 
Digitman   (2003-12-22 13:44) [1]

Occurs when the server socket needs to create a new execution thread for a connection to a client socket.

type
TGetThreadEvent = procedure (Sender: TObject; ClientSocket: TServerClientWinSocket; var SocketThread: TServerClientThread) of object;

property OnGetThread: TGetThreadEvent;

Description

Write an OnGetThread event handler to create a specialized descendant of TServerClientThread for the connection to the client socket. Create the new thread with the CreateSuspended parameter set to False, and return it in the SocketThread parameter. OnGetThread only occurs if there are no idle threads in the cache.

Most applications that use thread-blocking connections will want to create a new descendant of TServerClientThread in an OnGetThread event handler. This is because the default behavior of TServerClientThread uses the OnClientRead and OnClientWrite event handlers for reading and writing. These events occur on the server socket, which is not thread-local.

The Sender parameter is the TServerWinSocket object that received the client request. The ClientSocket parameter is the TServerClientWinSocket object that will communicate with the client socket.

Note: The OnGetThread event handler for TServerWinSocket is also set when setting the OnGetThread event handler of the associated TServerSocket.



Страницы: 1 вся ветка

Форум: "Основная";
Текущий архив: 2004.01.09;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.44 MB
Время: 0.011 c
3-25188
perova
2003-12-12 13:42
2004.01.09
Уважаемые мастера, подскажите, пожалуйста, как скрыть сценарий БД


14-25513
Stilgar
2003-12-15 20:17
2004.01.09
Чем Windows 2000 лучше XP?


7-25616
Seldon
2003-10-29 19:47
2004.01.09
Системные шрифты


1-25286
kotel
2003-12-25 16:53
2004.01.09
Панель инструментов


1-25390
Talla2k
2003-12-24 03:00
2004.01.09
TADVstringgrid





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский