How to make simple chat app?

I've learnt basics of C++ programming, but I don't know how to make a simple chat application with winsock in C++. I'm using MiniGW compiler so if anybody could give me an example of server and client app using winsock. Not something very advanced just something for beginner to learn from.

Thanks!
if you google you can find many simple chat programs or client/server app's using winsock or any socket api.
Also, if you dont want to invent anything new you can use some already tested libraries like boost, QT which provide socket classes and you just need to send and recv data using them.

The simplest way using sockets is like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
server							client
open socket
start listening
							client will create a socket
							try to connet to server
server will accept or reject
server will wait for any data in recv
							if accepted, send a string
							will wait for the response from server
server will recv the string and print
the user will type some response
send it to the clinet and wait
							accept and send again
accept and send again
...
...
...
							client will close when its done.
server will wait for some other client
or it may close.


this is the simplest way and using some c++ library can be more easy. to handle multpile clients you may need threads which can be implemented in next version.
Last edited on
Topic archived. No new replies allowed.