Re: socket lock in multithred programming
From: Ku Jaguk (jkku_at_softeleware.com)
Date: 09/29/05
- Next message: David Schwartz: "Re: socket lock in multithred programming"
- Previous message: Dan Stromberg: "Increasing TCP buffer space on AIX 5.1?"
- In reply to: Pascal Bourguignon: "Re: socket lock in multithred programming"
- Next in thread: David Schwartz: "Re: socket lock in multithred programming"
- Reply: David Schwartz: "Re: socket lock in multithred programming"
- Reply: Pascal Bourguignon: "Re: socket lock in multithred programming"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 29 Sep 2005 11:26:19 +0900
First, it's not the homework.
I used to make a socket program, even multithreaded socket program and i
have read enough books about the socket i think.
Even Stevens book socket programming, I don't think it mentions about one
thread only reading to and the other thread only writing from the same
socket descriptor.
I have tried all the case of socket server processes in real environment
those are mentioned in Stevens socket programming 1, such as single process
server, dynamic fork, pre-fork, dynamic spawning thread, pre-threaded, even
i anylized the current Apache web server, Hybrid multithreaded socket which
has pre-fork and pre-thread.
you said i should look at the socket man page, i just read all man pages but
i can not find about it.
I am sincerely saying that i can not find about what i mentioned. and i
really curious about it.
If the threads doesn't need to lock the same socket description, i think it
would be more efficent to have two threads hanle the socket IO, because i
useally making a client socket program which has limited connection to
server, and i don't like polling the socket.
Thanks in advance,
Jaguk Ku
"Pascal Bourguignon" <spam@mouse-potato.com> wrote in message
news:871x39gxq5.fsf@thalassa.informatimago.com...
> "Ku Jaguk" <jkku@softeleware.com> writes:
>
>> Hi there,
>>
>> I am making a multithreaded process.
>> it has a tcp/ip socket and two threads, one thread for sending message to
>> socket, the other for receiving a message from socket. i don't know it's
>> a
>> good architecture or not for socket programming.
>>
>> the question is
>> 1. Does it need to lock(for example mutex lock) the socket in both
>> threads
>> whenever sending to and receiving from socket?
>>
>> 2. If it need to lock the socket, why?
>>
>> 3. If it doesn't need to lock the socket, why?
>>
>> 4. If it doesn't need to lock the socket, which thread should close the
>> socket? if one thread close the socket and set socket fd with -1 value
>> without locking it, what happend to the other thread when it access the
>> socket fd?
>>
>> 5. If it need to lock the socket, i think i don't need to make two
>> threads,
>> just one thread is ok. am i right?
>
> Sounds like homework.
>
> Try reading some more man pages and course material.
> Start with:
>
> man 2 socket
> man 7 socket
> man 2 close
>
> and some tutorial about unix, processes, file descriptors and
> threads. (Use google).
>
> --
> __Pascal Bourguignon__ http://www.informatimago.com/
> Small brave carnivores
> Kill pine cones and mosquitoes
> Fear vacuum cleaner
- Next message: David Schwartz: "Re: socket lock in multithred programming"
- Previous message: Dan Stromberg: "Increasing TCP buffer space on AIX 5.1?"
- In reply to: Pascal Bourguignon: "Re: socket lock in multithred programming"
- Next in thread: David Schwartz: "Re: socket lock in multithred programming"
- Reply: David Schwartz: "Re: socket lock in multithred programming"
- Reply: Pascal Bourguignon: "Re: socket lock in multithred programming"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|