954,518 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

send value from php webapp to c# windows form

How can I send a string from php page to c# windows form using socket? Can you give me some example?

SuperErik
Newbie Poster
2 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

Develop a php page that returns a plain text string. And then request that URL in C# windows application using webrequest class.

Sample code is here: http://ask4asp.net/post/2009/05/13/fetching-URL-contents-into-a-string-using-HttpWebRequest.aspx

Above code is stated to retrieve the html content of the URL submitted in the argument. As your php file will return only the string, you can directly save it and then use it in your further processing.

thewebhostingdi
Junior Poster
168 posts since Jun 2009
Reputation Points: 3
Solved Threads: 14
 

SuperErik,

Use classes from System.net namespace - WebClient

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

thanks for the help.
the problem is the opposite.
The c#application interact via serial port to a modbus device and do a lot of stuff (monitor temperature, save data to db, .....) all works ok.
The php app need to execute a command on the c#app. For example a user can stop monitor tempertaure sending a string "STOP" to c#app throught socket next i can parse the string and do the designated method.
I don't know is the better mode to do what i need.
Thank again

SuperErik
Newbie Poster
2 posts since Jul 2009
Reputation Points: 10
Solved Threads: 0
 

you are looking for a server application. it cant be a windows application in this case. it must be on all the time. it can be a windows service application which will be listening on some certain port.
have a look at this
http://www.c-sharpcorner.com/UploadFile/ialam/CreatingWebServerInCS12022005042042AM/CreatingWebServerInCS.aspx

serkan sendur
Postaholic
Banned
2,062 posts since Jan 2008
Reputation Points: 854
Solved Threads: 127
 

examine the attached example, run both the server and the client solution at the same time and you will understand what is it all about.

Attachments Advanced_.NET_Framework_(Networking)_-_Use_Sockets_.zip (194.86KB)
serkan sendur
Postaholic
Banned
2,062 posts since Jan 2008
Reputation Points: 854
Solved Threads: 127
 

I think you are looking for comet.

__avd
Posting Genius (adatapost)
Moderator
8,648 posts since Oct 2008
Reputation Points: 2,136
Solved Threads: 1,241
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You