ASP.NET and Python Communication -


i trying send message asp.net website python file running on raspberry pi. if code on python on pi

import socket  serversocket = socket.socket(socket.af_inet, socket.sock_stream) serversocket.bind(('localhost', 8089)) serversocket.listen(5) # become server socket, maximum 5 connections  while true:     connection, address = serversocket.accept()     buf = connection.recv(64)     if len(buf) > 0:     print buf     break 

i need getting started. assuming know external , internal ip address of raspberry pi running python code, how started code using asp.net?

would use socket.io or else? best idea or method communicate between asp.net website , python? know question general need started in right direction.

(edit ) improved asp.net code:

protected void page_load(object sender, eventargs e) {      tcpclient client = new tcpclient("192.168.1.107", 8012);      // translate passed message ascii , store byte array.     byte[] data = system.text.encoding.ascii.getbytes("hello there");      // client stream reading , writing.     //  stream stream = client.getstream();      networkstream stream = client.getstream();      // send message connected tcpserver.      stream.write(data, 0, data.length);      // receive tcpserver.response.      // buffer store response bytes.     data = new byte[256];      // string store response ascii representation.     string responsedata = string.empty;      // read first batch of tcpserver response bytes.     int32 bytes = stream.read(data, 0, data.length);     responsedata = system.text.encoding.ascii.getstring(data, 0, bytes);     response.write(responsedata);      // close everything.     stream.close();     client.close();     } } 

is working , using now. there better option? thank replys. :)


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -