I am going to develop a chat application, I am confused which way I choose. Below are the option, please suggest me which/why is the best way to create a chat application.
WCF Duplex chat
Socket
XMPP
Thanks
Anuj
if you are going for a client server style of chat then ive always found using sockets to be a simple way to do it. If you create the server and add the socket you want it to be listening at.
Create a client that will then connect to the server for this you will enter the ip of the server and the socket. The client then connects to the server and the server will add the client to the client list. When the client sends a message to the server the server will then use a loop the send the message to all the clients in the list.
You will need to make this multi threaded as the clients will always need to be listening for new messages being sent from the server while still allowing the user to send new messages to the server. Its not very complicated at all a quick google and you will find all the code you could ever need for it
Related
My app communicates with an external server using AsyncSocket as a Client.
(the working code can be found here)
When the app starts, the user types in the IP address of the server computer.
assuming both iOS and server is sitting on the same subnet
Question: is there a way to "scan" the network for the server thus avoiding the user manual input for server IP ?
I can iterate the IPs one by one in a loop (10.0.1.x 10.0.1.x++)
yet it seems wrong and wasteful.
is there another more elegant way to do so?
I had an iOS project doing server discovery in the current (Wi-Fi) network. The typical solution is to use UDP broadcasting to ask for server info and then listen to a UDP response. As soon as you get the response with the server address you can establish connection using TCP sockets.
CocoaAsyncSocket is good enough for this. I used GCDAsyncUdpSocket and GCDAsyncSocket.
I understand you probably need more info on the topic. I'll try to extend the answer when I have time to.
I am trying to build a group chat application using UDP. One of the client sends a request to the server
and server replies the same message to all the clients in the group. Same like whatsApp group chat. I am confused whether each client behaves as a server or should there be a single server which send the message to all the clients. I have searched over the internet, I couldn't found the answer and so I am asking here and I felt it is not a duplicate.
If you want to receive UDP traffic you have to be a "server". UDP is connection-less. There are no clients or servers. In order to receive you have to open a port.
I have a simple TCP server and client working but can only communicate from client to server, i would like to know how to forward all incoming messages to all clients, when the client connects they would have to be stored, not sure how to do this, thanks in advance.
The code does not use Winsock control!
The examples are on the microsoft website, http://msdn.microsoft.com/en-us/library/w89fhyex(v=vs.110).aspx
Keep a list of Sockets in your application. Whenever a client connects add it to this list, and remove it when it disconnects. Whenever you receive a message just loop through this list and resend the message to each client, optionally ignoring the client that originally sent the message. I really can't get more specific without knowing exactly where you intend to take the design.
How can I construct chat application, without main server?
I think about hosting WCF service on each computer that connect to network, and trying to connect in loop on all available hosts in LAN. Simple scenario after launching my chat application:
start host chat wcf service
connect my client to my own service
search available hosts in LAN (e.g if is open on the appropriate port)
trying to connect to chat wcf service hosted on them
other machines are conecting to my service
To sending messages each machine use it's own service.
Each service is storing connected clients, and removes user that is disconnected.
I don't like this solution too much, so maybe do you have some better idea?
To achieve this my best bet will be
implement a small UDP boardcast on each WCF Service so each client knows whenever any new client gets connected.
The UDP can also be implemented with WCF Discovery
I made a simple chat system that connects to a server with a client one on one. I'm not really sure how to get multiple clients with the server so that you can see everyone's messages. Here is the source code. The Server only accepts one client at a time. how can I fix this?
Thanks,
Kevin
In keeping with what you have done so far, here are a few tips to get you started. First, when the client receives a connection it stops listening for new connections.
TCPL.Start()
TCPL.BeginAcceptTcpClient(AddressOf OnConnect, Nothing)
Calling these two lines after one client connects will allow another client to connect. Second, the client should not be responsible for starting the server. By doing this each client has it's own server. The clients will never be able to send a message that is displayed on other clients when they each have their own server. Third, I would move server.vb into it's own project. That way the two are not coupled. These steps will allow the server to accept multiple clients. At this point multiple clients will be able to connect and the server will see the messages from each client, but the clients will not be able to see each other's messages. I will leave the last hurdle to you.