Multi-Client Server communication when server is offline - c#

So I want to create a Multi-Client/Server application. I know multiple clients can connect through one port, and I want to allow for the messages to be stored in a list when the server is "offline".
I'm having trouble finding information online to help me understand how the server can tell the difference between the multiple clients on the port. For example, if a 2 clients send messages to the server while it is offline and I store them in a list, how would I be able to tell the server that this message came from this client first so answer that, and then this message came from this client next?
Is there any information online on an easy way to achieve this? Any help would be greatly appreciated.
Sorry, I didn't make it very clear. I'll try again! Ok basically I want like a middleware between them so that the clients contact the middleware with the message, the middleware checks if the server is online and if so it sends it on, otherwise it will store the message(s) until the server is connected again. Does this make more sense? I'm not great at explaining myself, sorry again!

There seems to be some confusion of concepts here. When client are not connected they obviously can't send anything to the server and also don't have a port. Conversely, when the server is running and clients connect to it, the server has an object for each connection, representing each client.

Related

send a server a life signal from remote client

I have about 300 remote computers that send data to my server. i have a windows service that i made with a console aplication which reads data from energy meters and sends alarms via email. I need to know if one of them is offline for more than one day.
the remote clients doesnt have a fixed IP address so i assume that the client would have to make the contact.
i toghut about using signalIR to send a simple messeage to the server and let it know that the client is online, but i have no idea how to do it. i also raed about helth checks but i am not sure that's what i need.
what will be the easiest way to send a short message from a client to a server?
Thank you, Shay.

Redirect all program packets through alerternate port

I have an application I need to debug.
The application connects to a server using a specific UDP port, though the application can be configured to join any server with any UDP port.
My goal is to be able to view all incoming data/packets from the server, and be able to accurately send my own packets from my application to the application I want to debug to see and learn from the effects.
My idea was to use some sort of web service to redirect all traffic, sent and received through. With this in mind, I could process the data being received from the server and choose when I want to send my own packets between data being received from the official server.
I am fluent in VB.NET and C#, if anyone has any tips or ideas to help kick-start this project! Thank you to all who helpout! :)
Search for packet injection if you're interested in this. You can forward all your data through your own proxy/vpn and study the data there.

P2P app chat with WCF

I followed the example on this link.
It worked pretty well - but it worked like a Chat Room.
I dont know how to just send and get message between just 2 clients.
Can someone give me some advices to do that?
Thank you for reading.
As far as I know you cant have only clients. You need to have both, a client and a server.
If you are trying to make a chat program with only 2 users, one of the users needs to act as a server and the other as the client. You only need to put a constraint on the server to allow only one client.

C# TCP/IP server and client

i have a simple TCP client/server application. How do set up the two program so on the server side it requires a username and a password, and when the client tries to connect, they have to enter the correct user name and password and send it to the server side, the server side will check to see if thats the correct username and password, if its correct then it allows connection, otherwise it rejects the connction
Use WCF since you obviously have not used pure sockets before. It's will most probably be a more stable solution then if you try to learn sockets AND invent your own protocol.
You can use WCF together with the netTcpBinding to achieve what you want. You got a example here: http://www.dotnetspider.com/resources/19314-Client-server-sample-using-WCF-net-tcp-binding.aspx
I'm sorry if this wasn't the answer you where looking for, but there is a lot that need to be implemented correctly to get a hassle free tcp/ip client/server solution.
This can not be done using simple TCP/IP. You'd either have to invent some kind of protocol or use WCF or the like.
As the "connect" happens before anything can be sent, there's no way of sending credentials "along with the connect". You'd have to have the client connect, receive a command for "Login", check credentials and pass back some unique identifier that then needs to be sent along with every command so the server can check whether the client was authenticated. That's how I'd do it if WCF was not an option.
White Thorsten is technically correct, I still think there is a solution:
Let the server accept all connections, but then expect as the first data in the connection the username and password. If they are incorrect, the server will then close the connection, and not process any requests that the client may have sent on the connection.

Creating a heavily restricted server discovery application in c#

I am writing you because of a new problem I need to solve, and I have now been banging my head against a wall for too long now.
Basically, I need to create an application that can take care of the following:
A user starts an app, which sends a broadcast to the subnet, and recieves a response of all servers there with their IP (and some additional info). The user can then select what server he wants to connect to.
Making it work is simple enough, with identifying the subnet, and broadcasting with UDP, and then having a different server application recieving it and sending back a response . The problem lies with these restrictions, that I need to take into consideration:
There will most likely also be clients on the server machines in the network, meaning that we can assume that the application is present on all machines. Every machine needs to have the listener running, and every machine can launch the GUI for selecting a server.
I am only allowed to add one exception to the firewall - an exception that handles both sending out the broadcasts, recieving broadcasts, sending answers and recieving answers.
I should also only be adding one Windows Service
on a server machine, the listener should run as a windows service, so the user won't notice it. Nor will the user notice, that the response is sent back to the client.
On the client machine, the user can start an application, which will notify the application to emmit the broadcast, and will get all the server responses, so the user can choose one to connect to.
Besides from the application that the user launches in order to select a server, there should be no interaction with the user whatsoever. Not even a popup, requesting the user to allow traffic trough the firewall - it should all be automatically
It needs to work on and in between Win XP, Win Vista and Win 7.
I don't know if I am putting too many constrains on myself, but I really hope that I can make the application with these requirements.
I have a few ideas - I just need to figure out how to do it:
Should i make everything into one application, that I add to the firewall exception list, so it will take care of the traffic on both the server and the client machines?
Should I add a custom exception to the firewall, allowing UDP traffic on a specific port, and then have all traffic flow trough that?
Is there a third and better option for managing that?
It is OK to have the service running on both client and server machines. But can it take care of everything for me - like it handling both the broadcast send/recieve and answer send/recieve? And is there any way to extract the information about servers on the network from a service?
I know it is a lot, but I really hope that you will be able to help me out.
let me know if I wasn't clear enough, or if you need further explanations.
I am coding in C# .Net, and I can utilize all I want from the .Net framework. As soon as I have this functionality implemented
All the best
/Sagi
The kind of peer-to-peer networking problems become simple to the point of being trivial if you designate one machine as the master server. It should have a well-known name that all sub-servers can connect to so they can publish (and withdraw) their availability. A client can then send a query request to the same server and get a list of known servers in return.
This can also solve your firewall problem, the master server could be listening on port 80.
Look into the System.Net.PeerToPeer namespace for a p2p solution supported by the framework.
Maybe a UPnP server and client may be a solution to your problem?

Categories

Resources