I use ASP.NET MVC with C# for web development and I am curious about creating a web-based telnet server. I've actually never done anything with telnet, but I'm fairly certain I understand the basics of it as a simple protocol. Do I need to be running an application listening on a port to establish a socket connection with a client, or does telnet also operate in a request/response format so that it could talk to an MVC-style web service instead of an actual running server program listening on a port.
Let me know if I have absolutely no idea what I'm talking about. I really just need pointed in the right direction.
Keep in mind that I am talking about a telnet server, not a client.
Thanks in advance.
You can either create a telnet server, or a telnet client. But where is web in it? I can't see it. If you really want to make a server, you can simply make a telnet server and you don't need the web.
If you want to make a telnet client on a web page, it makes sense. Users will use their web browser, and your application will act as a bridge between the real telnet and web browsers. Your application will act as a telnet client on one side and transfer all data to and from human user using web pages. It is a real time thing so I would prefer client code for this, like Silverlight, where IMO you can achive quite good result.
You can telnet to a web server and interact with it over HTTP, but you can't make the server behave like a telnet server unless you bind to a different port and run telnet over that port. At that point the fact that your hosting it in a web server is pretty superfluous though, so I'm not sure why you would do that.
Related
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 develop sock5 proxy server in c# which could make connections to client.
i.e in normal scenarios client or browser make connection to proxy server but i want the proxy server to connect to the client.
i googled a lot but could not find any code sample in c# or other language.
This sounds like a rather broad question, but generally I think what you are trying to do isn't "by definition possible". Socks5 is defined in RFC1928 (https://www.rfc-editor.org/rfc/rfc1928). It specifically relates to the 'client' connecting to the 'server'. In order for the proxy server to connect to the client, the client machine would have to have some form of service running and listening on a previously established port (assuming TCP/IP here). I suppose you could write some form of browser plugin or a service daemon to listen for server initiated connections; however, this wouldn't technically be 'socks5'. Having an open port (service) on your client open other security concerns, such as a connection from a machine claiming to be your server, or an outside machine requesting the proxy server to contact your client machine. Part of the trust model of these setups is the idea of client initiated actions. You may be trying to solve the wrong problem (i.e. you may need to reframe your problem in a different way).
I have a C# applications which acts like a client and it can be installed on any system which is directly connected to public internet (through data cards or port forwarding) or they can be behind router also (without port forwarding).
The other application which is developed using java acts like a server application which is on the public internet. Now, my java application wants to push a message to C# application which is behind router. Java application has the clients public and private (192.168.x.x) IP address. Java application is supposed to run 24x7.
So, now there are two options for me:
Whenever c# application starts it will establish a socket connection with java application and this socket connection will remain open till C# application gets closed.
Whenever Java application has something for C# application it will create a socket connection with C# application then it will push the message and then close the connection.
Now, with 1st option there is a problem that there will be lots of unnecessary connection since there can be thousands of client application and it may happen that on some day there will be nothing to push for some clients. and I don't know how to go for 2nd option.
What will be the right way to accomplish this task (option 1 or 2)?
Is UPnP protocol right for 2nd option? What are the open source UPnP libraries which has both the API's (C# and Java). I found one such called ohnet. Will it be a right thing for me? I didn't found a single small example for OhNet to test.
2) is not feasible if you don't have control over network configuration at the client end. It won't in general be possible for the server to make connections to the client if the client is behind any moderately secure firewall / router.
So you will in general have have to go for some variant of 1) where the client creates a connection to the server.
You don't necessarily have to keep the connection open though - it's always possible to get the client to poll the server periodically to check if there are any new updates.
If you want realtime updates to the client from the server then you will still need to keep a connection open. This isn't necessarily a problem if you use Java NIO you should be able to handle tens of thousands of simultaneous incoming connections relatively easily.
Using option 2, will you have to queue messages for your C# client until it connects? That could make your Java application run into out of memory problems if the C# application doesn't connect.
I would definitely use method 2 by adding a static route in the router (port forward). You should - however - ensure that the server behind the router is protected from the rest of your network (DMZ).
UPDATE:
Perhaps I have missed something here (method 1 or 2) :-) - but just to make it absolutely clear: It is always the client that should initiate the connection to the server. And yes, you could allow the client to request the server for updates on a regular basis.
I am creating a website where I need to have access to the clients files. I know that the client will have to accept some warning message and also run my progam.
I have reaserched on the internet and I know that I can acomplish this with Web Sockets. I have been able to establish a tcp connection localy from c# and google chrom html 5 websocket. the problem with websockets is that it did not work with other browsers.
Another solution that I was thinking was to use cookies to exchange messages. I havent tried that and I dont think that will be efficient.
Some websites when giving them privilades are able to use java. I have no idea how they exchange messages but maybe there is a similar way of doing it with c#
Look at SignalR -- https://github.com/SignalR/SignalR. Be careful though, web sockets (and any other "per user" type connection has server resource implications -- see http://robrich.org/archive/2012/04/05/The-real-time-web-in-ASP-NET-MVC.aspx
This topic has been discussed million times before, but let me clarify my needs:
I need a single server which controls a system and includes the necessary functions. Furthermore, there will be "n" Clients which represents only the HI/GUI and call server side functions. The server itself should be able to send data back to the clients and call client-side functions too (like shutdown, exit and so on...)
I have heard about duplex services/contracts (http://msdn.microsoft.com/en-us/library/ms731064.aspx), but I'm not sure how far I'll come with that.
How would you handle this?
I recently made a proof of concept app that made both the server and the client host a WCF service each. The client connects to the server and then in a handshake call, gives the server the connection information to allow the server create a separate connection back to the client. It worked a treat with multiple clients on network links from local lan to 64k line on remote sites at the same time.
You could use WCF, and host the service on the server in IIS, in the application on the client and let the client register it's endpoint on the server.