ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Hi
I have a problem.
i am writing this program. It works between Client and The server. The Server Listens to a namedpipe .whenever a client comes up and wants to login , The client is asked for it's userid. This user id has to be written in the named pipe(that has already been opened) and be sent to the server. The server is going to creat another exclusive named pipe with this information for this user.
My question is that i don't know how to write userid in named pipe and how to create exclusive named pipe for this user according to this userid.
Thanks so much
First of all. what language are you developing in?
Second, do you not intend to use this over the network? If so you may want to redesign using sockets now, as it will be more difficult to do it later if you need your app networked.
Third, to send data to a pipe you simply open it as a file object and write to it. Here's a trivial example using bash and python:
Sure. It's just a regular file object. You can operate on it as you can any other normal file. The only difference is that both ends must be open for data to pass, ie server must be open for reading and client must be open for writing.
Quote:
mk=mkfifo("here i want to use the username as the filename.how?) , 0777)
Well, you are getting the name of the user in your read call right? So just assign it to a variable and pass that to your mkfifo call. Depending on your code, you may have to clean it up a bit. I would imagine at the very least you will need to 'chomp' the newline character.
Sure. It's just a regular file object. You can operate on it as you can any other normal file. The only difference is that both ends must be open for data to pass, ie server must be open for reading and client must be open for writing.
And: The reading process must actually read away any data coming in from the pipe, because buffers for pipes are fixed as well as small.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.