I would appreciate if someone could help.
I have written a Client/Server Sockets application. The client is Windows Forms C# app and the server is a C# console app which runs locally. The client application has a login form containing the field with generated port.
When user logins he is connecting to the server using that port and the server continues listening incoming connections.
Everything works fine when I test my application simply running several instances of Visual Studio project on one PC. Now, I would like to test it on several PCs and I am very confused here.
I would be grateful if someone could explain in simle words how to run my app on two machines.
How do both users connect to the same server? Where should it be located? Should the server have one IP and different ports per one users group?
Also, my application uses SQL Server Database which is installed locally on one PC. So the application uses connection string with that PC Name. In case of two PCs is it possible to connect the second computer to DB on first PC?
I am sorry if this sounds silly :)
Thanks a lot
So if I am correct you are wondering the following three things?
Q1. How do I test my software in a multiple machine environment.
A: This is perhaps not really a Stackoverflow question but what I would do in this case is to have a small setup in Hyper-V with several machines with different operating systems that all have a shared folder that I can deploy my code to. Of course for more extended testing you would need to get more machines and copy the executables to that machine for testing for the first stage and perhaps write a setup software for the second stage of testing, but that depends on the how much testing you actually do.
Q2. How to I allow several users to connect to my service?
A: I think that Anthony Horne has a great answer to this in the comments - Tell your service to listen on port X and when a client tries to connect open a new communication instance on port Y and ask the client to call back to that port. This is as far as I know industry standard for solving this type of problem.
Q3. My application uses a SQL Server Database can I allow clients to connect to it remotely.
A: Yes you can. Please see this Stackoverflow question.
Related
I have to run my Web-Service project on two computers. I have created very simple project with tutorial helps, but it working only on localhost. Next thing I have to do is create a local network, where on first computer I will run web-server and second will be a client.
Do you have some ideas how to do this?
I'm new in C# and WS technology.
You can setup a Virtual Machine on your Computer to simulate a small local network.
The server socket must be bind to your network ip address or just 0.0.0.0, so that it is reachable from everywhere.
It would help to post some code here, to show what you already have done.
Ok, so I am a newbie with WebSockets, but I am creating a program which can be installed on a several of my home PCs to synchronize data and program state information.
After doing some preliminary research, I am thinking that WebSockets are the best route.
The problem I seem to be running into is that all the code samples I have found have separate Server and Client applications, and this makes sense in the context of the web, but in my situation I actually do not want a dedicated server (primarily because I don't want to have a "on all the time" instance, as this is an "OnDemand" program), I'd prefer the applications to be both Client and Server.
Can someone give me some insight into how this works? I assume it is possible to be both a client and server, do I just have a Client and Server object? Can the servers be the same port across all PCs?
Sure - you can have multiple servers, (listening on different ports), and clients in one app, if you want.
The servers can be on the same port on all you boxes 'cos they all have a different IP.
i want to built an application which is communication network between two emulator. i have already connect emulator with server.
Now i want to connect two emulators through server(C#) which is PC. like we sent sms through mobile networks.
I need guidance to start this.
I am not sure what your requirements are and how far you would go to implement best practices, however, here are some points to consider based on my experience on a similar application, just to make it clear we worked on a solution where many Android phones would connect to a server to send/receive data.
Web Service is the way to go, this is what web services are meant for, we created WCF based APIs for the applications connecting to the server.
You are working on a heterogeneous system Java on Android, C# on the Server, consider creating REST based APIs on the server for data transfer
Go through these to get a feel of what needs to be done onthe server...
http://www.codeproject.com/Articles/105273/Create-RESTful-WCF-Service-API-Step-By-Step-Guide
http://msdn.microsoft.com/en-us/library/dd203052.aspx
And this for what needs to be done at Android side...
http://docs.xamarin.com/android/tutorials/consuming_web_services
hope that helps....
I've created a 3 tier windows forms application. It works
fine on a LAN. But the problem that i'm facing right now
is that i want the client application to be able to connect
to the server database via the internet. Why via the internet? Because there is a chance that the server pc and
the client pc might become 250km apart.
The other thing is that, i want this connection to be a secured one. This means only specific computers are allowed to connect to this database.
Is there a way to accomplish this?
Is there an Ebook that i can read on, that will help me
accomplish this problem?
Thanks in advance
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?