Read Part 2 : The Client
Sample Execution:
$ gcc server.c -o server -lpthread $ gcc client.c -o client -lpthread
Now we run the server program and several client programs
Each client should first connect to the server by typing in:
login [alias]Here [alias] is optional, if it is not mentioned, the name will be set as Anonymous.
The name can be changed by the command:
alias [new_name]After this, you alias will be changed to the new name you have given.
To send a message to everyone connected at the moment:
send [message]
To send a message to a specific alias:
whisp [user_alias] [message]If the target alias is not active at that moment, message will not be sent anywhere
You can disconnect from the server by typing:
logoutYou can again reconnect by using the login command
You can terminate the client by typing:
exit
This is pretty much of it. Basically this is good for your C lab assignments regarding TCP / socket based chat clients. Here is a screen shot from my computer:
Good luck!
hi zobayer, i learn coding from your spoj solutions :)
ReplyDeleteI Know It's not the place to ask you this question here. But i really have a great problem in one of my project where i have to print a text file(*.txt) by a printer through C coding. Can you provide me some reference or instruction ?
ReplyDeletesee fopen(), fwrite(), fprintf() etc from www.cplusplus.com
Deletefor low level operations open() and read() / write() can help
Brother i am not asking you about file i/o system. May be i could not ask you the question properly at previous time. I want to access a peripheral or USB port Or may be the driver file in the system of the OS(windows) of my pc so that i can give instruction to the output device (such as printer) to print a text(*.txt) file. I really need some reference.
Deleteoh sorry, for windows, can't help, however in linux its pretty straight forward. you can get plenty of results by googling... good luck.
Deletehey bro , can u pls expalain me the solution of LIS2 in spoj
ReplyDeletehttp://www.spoj.com/problems/LIS2/
Waiting for your reply
Hi zobayer, l learn coding from ur spoj solution. but it seems that you have removed ur solution from GitHub. Have u posted them on other site?
ReplyDeleteHi, no, I didn't post them in any other site, I have taken those away on request, because people were abusing them too much. There are problems where 90% of the top 30 submissions were exactly my solutions. So I think instead of taking help, people are using those as a means of racking up their score. I also got a mail from spoj admin Ćukasz Kuszner regarding this issue. I hope you will understand. If you really need to see a solution that I have solved, send me an email, I will send you the source code if I feel appropriate.
DeleteThanks for understanding :)
Hi All,
ReplyDeleteCan Any one provide the Chat pgm in C-Language (Ex: Happening b/w two users ), thanks in advance and great appreciate if u provide the solution!
Thanks & Regards,
Ravi k.
thanks god i finally finish my IT homework :D thank you a lot !!!
ReplyDeleteAfter exit command in /.server, it exits well but when I rewrite ./server again it shows this "bind() failed..." in terminal. Can you help me please ???
ReplyDeleteThat is because the port is still active with the process. Make sure you release the port. You can check which ports are currently in use by using netstat command.
ReplyDelete