I have a C# .NET application listening on a specific port for data (SocketServer).
Using Android, I would like to connect to that SocketServer and send text data to it. I do not know where to get started - sample code would be great.
Take a look at TCP .NET/C# Server with Java client?.
Other than that, you could always recode your server into a REST service, and then anything can communicate with it. But I know this isn't a good answer as I'm sure you don't want to recode the server.
Related
I'm trying to write a 3rd party server application for sending and receiving notifications from Android devices using GCM's CCS as outlined here. I'm leveraging PushSharp for handling the sending of notifications from my server app, but I can't seem to find any documentation on how to receive messages at the server level. Is this supported or is there another 3rd party XMPP library for .NET that handles this cleanly?
I dont think you can receive messages at server level, this is not the point in push notifications. if you want to send information to the service from the app, i would suggest writing a webservice. i've implemented this myself, and had to do a little digging to find some code that could communicate with the webservice as it was written in c# and the app was java, but i can paste some code that might help if you think that would help you communicate.
Long story short though, if you want an app to talk to a server, then write a web service. if you want a server to talk to an app, use push notifications.
I am creating a "tracking system" for my android phone. Basically, the phone would transmit it latitude/longitude to a C# program that will receive the coordinates and display it on a map. I managed to get the phone's latitude/longitude coordinates but I need a way to transmit that data to my C# application running in my PC. I know my way around C# and Java but never really got into network programming. Is there a way to do this ?
I'd look into C# Webservices, very powerful. The communication protocol is SOAP (Simple Object Access Protocol) which is a popular and well supported standard.
Good starting reference: Your first C# Web Service
I can't speak to the C# side of it, but if you write a C# server to receive post requests, the Apache HttpClient makes it relatively simple to send requests. There are a bunch of other questions on SO that will help with setting up the client side on your phone if you poke around a bit.
You have different way to do it.
The first is to send data over the cloud to interact through distant server. So the both devices have to be connected to Internet
The second id to send the data over a local network so the data have to be on the same network and have to share their IPs
The third is to use adb forward which allows to build a socket connection between the 2 devices over a USB cable. The requirements are that the phone have to be on debug mode I think and that the driver are installed on the PC so the phone is recognized by ADB.
I can add one more by using a Bluetooth connection. Find information here
The correct way to do it would be to build WCF service which allows many different protocols to receive data. This would could be a very powerful solution that can be extended in future.
The fastest and easiest IMO would be to create ASP.NET MVC application, define a POCO Model for your longitude/latitude and create an action that would take your Model as parameter. Then use HttpClient and HttpPost on android to send the data. The trick here is to name the variables in your post request same as ones you define in your C# Model.
I need help with small app I am working on.
Its small client collecting some data from user and I need to sent them to server and receive data from server... Last time I made it: client in c# was getting data from server through webserver PHP...(sending POST request via c# and parsing output page) It will be beter to have TCP/IP connection...
Whats the best and easy solution to do that? I have skills in php, c# (not c++)
Does MONO support all c# socked functions? Is it possible to run MONO on linux debian server without graphical interface.. (bash only)?
I need to: send/receive data and authenticate user...
thx for help
I am starting to program in C# and build applications over the web.
I have a board with a PIC microcontroller that I made that communicates with the PC via USB-Serial converter (FT232).
Now I want to do this: I want to create a website on another computer that allows you to communicate with the PC with the PIC board. Via the other computer I want to be able to control the PIC board.
I think that in order to do that I have to start learning about ActiveX, if I'm not mistaken. Does ActiveX allow me to write on another computer's serial port?
I really want to learn that.
Could you please guide me in the correct direction, and if possible a book or tutorial?
Thank you very much, and sorry for any english mistakes.
No, ActiveX is to let a web page interact with the computer of the visitor of that web page, an old system which should not be used again. Although HTML5 seems to want to reimplement a lot of ActiveX-like functionality again, this is not what you want.
If you create a C# application or service that uses the SerialPort class to talk to your PIC, and use for example a WCF service to accept commands over the internet.
You can then create a web page that lets the user issue commands, while the back end of the web page calls the WCF service to send the command to the PIC.
You could build a website or a webservice which runs on the computer with the PIC board. This website would allow you to send commands to the local attached board.
If you have got a .NET SDK for your board you should be able to wrap all the commands in the service or website.
Might look at something like this product http://www.virtualserialport.com/products/serial-over-ethernet/, if you want to make it look like a local serial port. If that's not necessary, I'd write a service that listened on a socket and simply sent the serial data between the socket and the serial port.
I have been doing research for a few months now on the possibility of client-server communication. I have experimented with many methods such as WebORB and FluorineFX, which are both servers designed to deal with client/server authentication.
WebORB only runs on Windows for their .NET version as far as I can tell, and I would much rather use an open source system. I have tried using FluorineFX, but I think their must be a simpler way for me to build my own simple system from the ground up.
I have been using Dropbox for a while now, and I like the way that the client-server communication is instant. As far as I can tell (from some Google searches) the client doesn't open a port of its own, and just communicates with the Dropbox server through port 80. An example of its instant communication is where you may delete a file on Dropbox on their website, and instantly the server communicates with the client telling it what has happened. I don't know how this instant communication is possible without opening a port.
I can create a system that uses fetching from the client, asking the server every 10 seconds or so to see if there are any updates, but I would like a method to be able to push the information from the server to the client.
My server runs Linux so I don't think I can use WCF, and ideally I am looking for a way to make PHP and C# communicate with each other.
I would love to hear any advice that anyone has and how they deal with the problem.
Cheers.
You CAN use WCF to communicate with any platform. Just make sure you're using an endpoint which your target machine support: http://msdn.microsoft.com/en-us/library/ms733107.aspx
Have you tried the good old .NET Remoting which runs perfectly with Mono?
You can choose between a TcpChannel (for performance) and a HttpChannel (to pass proxy/firewall easily).
For push notifications, you can open a connection to your server and wait for an answer indefinitely.