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.
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 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
I am publically distributing an application which can be installed on users PC. Client will periodically communicate with the server to send information from the client. Server have to acknowledge the successful receipt of the information. Occasionally, server will do an one way communication with the client. My question is what is the best/failproof/recommended way to do client-server communication when client is massively distributed? I am currently focusing on self-hosted service to do the communication. What precaution should i take if the clients ip address change frequently?
My suggestions are:
Use HTTP or HTTPS on default ports. By massively I understand you will have no control over the network restrictions, firewalls, NAT traversal, etc. Using HTTP(S) and initiating the connections from the clients with simple web requests will save you a lot of trouble.
Use polling at regular/smart intervals to solve your occasional server initiated data transfer. Clients running on workstations wont have a public IP address, let alone a fixed one.
I want to write a simple SMPP Server that basically forwards traffic to another SMPP server (C#, PHP). What are the things I need to know? How do I proceed?
With regards to Goran's comment, one possible solution would be a simple tcp proxy such as simpleproxy.
From the Ubuntu package description:
simpleproxy acts as a simple TCP proxy. It opens a listening socket on
the local machine and forwards any connection to a remote host. It can be
run as a daemon or through inetd.
Olaseni,
I've done something similar in the past, but i used perl. What i did was taking a port forwarding proxy which i downloaded from accordata.com. (port-proxy.pl)
I modified this to use the NET::SMPP module to validate PDU's when reading the incoming socket. Once the PDU was of type "Bind_request" i would validate against a dbase, replace credentials if validation was successfull and than forward or if credentials were not validated, issue a reject to the client and disconnect. Alternatively if the PDU contained anything else, i would forward using the logic that was already existing in port-proxy.pl.
You can write simple smpp lib and forward smpp traffic from many applications to the one smpp connection to the sms provider
I can advice you jsmpp lib, but it's for java. It's very simple and cool lib. Many low level things happen behind the scenes and you can focus on your business logic
Find more here
I have written exactly what you are asking for in vb.net
What i did was listen for inbound PDU (connect, bind, sms, and disconnect too) identifying each inbound connection uniquely - for the authentication bit,
then i forward the traffic onward to the delivery smsc.
Your SMPP service simply needs to listen for inbound PDU packets... as well as send heartbeat packets to the connected clients, if required.
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.