1.
sudo apt-get -y install ttf-wqy-zenhei
2.
sudo apt-get -y install ttf-wqy-microhei
3.
sudo apt-get -y install fonts-arphic-ukai
4.
sudo apt-get -y install ttf-arphic-uming
sudo apt-get install apache2 -y
/var/www/html/index.html
.cd /var/www/html
ls -al
sudo apt-get install php5 libapache2-mod-php5 -y
index.html
file:sudo rm index.html
index.php
:sudo nano index.php
<?php echo "hello world"; ?>
<?php phpinfo(); ?>
const int ledPin = 13; void setup(){ pinMode(ledPin, OUTPUT); Serial.begin(9600); } void loop(){ if (Serial.available()) { blink(Serial.read() - '0'); // convert the character '1'-'9' to decimal 1-9 } delay(500); } void blink(int numberOfTimes){ for (int i = 0; i < numberOfTimes; i++) { digitalWrite(ledPin, HIGH); delay(100); digitalWrite(ledPin, LOW); delay(100); } }
import serial ser = serial.Serial('/dev/ttyACM0', 9600)
ser.write('3')
void setup(){ Serial.begin(9600); } void loop(){ Serial.println("Hello, World!"); delay(1000); }
import serial ser = serial.Serial('/dev/ttyACM0', 9600) while 1 : ser.readline()</span>
'Hello, World!\r\n' 'Hello, World!\r\n' 'Hello, World!\r\n' ...
#handling errors in python socket programs
import
socket
#for sockets
import
sys
#for exit
try
:
#create an AF_INET, STREAM socket (TCP)
s
=
socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except
socket.error, msg:
print
'Failed to create socket. Error code: '
+
str
(msg[
0
])
+
' , Error message : '
+
msg[
1
]
sys.exit();
print
'Socket Created'
import
socket
#for sockets
import
sys
#for exit
try
:
#create an AF_INET, STREAM socket (TCP)
s
=
socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except
socket.error, msg:
print
'Failed to create socket. Error code: '
+
str
(msg[
0
])
+
' , Error message : '
+
msg[
1
]
sys.exit();
print
'Socket Created'
host
=
'www.google.com'
try
:
remote_ip
=
socket.gethostbyname( host )
except
socket.gaierror:
#could not resolve
print
'Hostname could not be resolved. Exiting'
sys.exit()
print
'Ip address of '
+
host
+
' is '
+
remote_ip
import
socket
#for sockets
import
sys
#for exit
try
:
#create an AF_INET, STREAM socket (TCP)
s
=
socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except
socket.error, msg:
print
'Failed to create socket. Error code: '
+
str
(msg[
0
])
+
' , Error message : '
+
msg[
1
]
sys.exit();
print
'Socket Created'
host
=
'www.google.com'
port
=
80
try
:
remote_ip
=
socket.gethostbyname( host )
except
socket.gaierror:
#could not resolve
print
'Hostname could not be resolved. Exiting'
sys.exit()
print
'Ip address of '
+
host
+
' is '
+
remote_ip
#Connect to remote server
s.connect((remote_ip , port))
print
'Socket Connected to '
+
host
+
' on ip '
+
remote_ip
import
socket
#for sockets
import
sys
#for exit
try
:
#create an AF_INET, STREAM socket (TCP)
s
=
socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except
socket.error, msg:
print
'Failed to create socket. Error code: '
+
str
(msg[
0
])
+
' , Error message : '
+
msg[
1
]
sys.exit();
print
'Socket Created'
host
=
'www.google.com'
port
=
80
try
:
remote_ip
=
socket.gethostbyname( host )
except
socket.gaierror:
#could not resolve
print
'Hostname could not be resolved. Exiting'
sys.exit()
print
'Ip address of '
+
host
+
' is '
+
remote_ip
#Connect to remote server
s.connect((remote_ip , port))
print
'Socket Connected to '
+
host
+
' on ip '
+
remote_ip
#Send some data to remote server
message
=
"GET / HTTP/1.1\r\n\r\n"
try
:
#Set the whole string
s.sendall(message)
except
socket.error:
#Send failed
print
'Send failed'
sys.exit()
print
'Message send successfully'
#Socket client example in python
import
socket
#for sockets
import
sys
#for exit
#create an INET, STREAMing socket
try
:
s
=
socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except
socket.error:
print
'Failed to create socket'
sys.exit()
print
'Socket Created'
host
=
'www.google.com'
;
port
=
80
;
try
:
remote_ip
=
socket.gethostbyname( host )
except
socket.gaierror:
#could not resolve
print
'Hostname could not be resolved. Exiting'
sys.exit()
#Connect to remote server
s.connect((remote_ip , port))
print
'Socket Connected to '
+
host
+
' on ip '
+
remote_ip
#Send some data to remote server
message
=
"GET / HTTP/1.1\r\n\r\n"
try
:
#Set the whole string
s.sendall(message)
except
socket.error:
#Send failed
print
'Send failed'
sys.exit()
print
'Message send successfully'
#Now receive data
reply
=
s.recv(
4096
)
print
reply
import
socket
import
sys
HOST
=
''
# Symbolic name meaning all available interfaces
PORT
=
8888
# Arbitrary non-privileged port
s
=
socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print
'Socket created'
try
:
s.bind((HOST, PORT)) # it must has two ()..
except
socket.error , msg:
print
'Bind failed. Error Code : '
+
str
(msg[
0
])
+
' Message '
+
msg[
1
]
sys.exit()
print
'Socket bind complete'
s.listen(10)
print
'Socket now listening'
import
socket
import
sys
HOST
=
''
# Symbolic name meaning all available interfaces
PORT
=
8888
# Arbitrary non-privileged port
s
=
socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print
'Socket created'
try
:
s.bind((HOST, PORT))
except
socket.error , msg:
print
'Bind failed. Error Code : '
+
str
(msg[
0
])
+
' Message '
+
msg[
1
]
sys.exit()
print
'Socket bind complete'
s.listen(
10
)
print
'Socket now listening'
#wait to accept a connection - blocking call
conn, addr
=
s.accept()
#display client information
print
'Connected with '
+
addr[
0
]
+
':'
+
str
(addr[
1
])
import
socket
import
sys
HOST
=
''
# Symbolic name meaning all available interfaces
PORT
=
8888
# Arbitrary non-privileged port
s
=
socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print
'Socket created'
try
:
s.bind((HOST, PORT))
except
socket.error , msg:
print
'Bind failed. Error Code : '
+
str
(msg[
0
])
+
' Message '
+
msg[
1
]
sys.exit()
print
'Socket bind complete'
s.listen(
10
)
print
'Socket now listening'
#wait to accept a connection - blocking call
conn, addr
=
s.accept()
print
'Connected with '
+
addr[
0
]
+
':'
+
str
(addr[
1
])
#now keep talking with the client
data
=
conn.recv(
1024
)
conn.sendall(data)
conn.close()
s.close()
import
socket
import
sys
HOST
=
''
# Symbolic name meaning all available interfaces
PORT
=
5000
# Arbitrary non-privileged port
s
=
socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print
'Socket created'
try
:
s.bind((HOST, PORT))
except
socket.error , msg:
print
'Bind failed. Error Code : '
+
str
(msg[
0
])
+
' Message '
+
msg[
1
]
sys.exit()
print
'Socket bind complete'
s.listen(
10
)
print
'Socket now listening'
#now keep talking with the client
while
1
:
#wait to accept a connection - blocking call
conn, addr
=
s.accept()
print
'Connected with '
+
addr[
0
]
+
':'
+
str
(addr[
1
])
data
=
conn.recv(
1024
)
reply
=
'OK...'
+
data
if
not
data:
break
conn.sendall(reply)
conn.close()
s.close()
import
socket
import
sys
from
thread
import
*
HOST
=
''
# Symbolic name meaning all available interfaces
PORT
=
8888
# Arbitrary non-privileged port
s
=
socket.socket(socket.AF_INET, socket.SOCK_STREAM)
print
'Socket created'
#Bind socket to local host and port
try
:
s.bind((HOST, PORT))
except
socket.error , msg:
print
'Bind failed. Error Code : '
+
str
(msg[
0
])
+
' Message '
+
msg[
1
]
sys.exit()
print
'Socket bind complete'
#Start listening on socket
s.listen(
10
)
print
'Socket now listening'
#Function for handling connections. This will be used to create threads
def
clientthread(conn):
#Sending message to connected client
conn.send(
'Welcome to the server. Type something and hit enter\n'
)
#send only takes string
#infinite loop so that function do not terminate and thread do not end.
while
True
:
#Receiving from client
data
=
conn.recv(
1024
)
reply
=
'OK...'
+
data
if
not
data:
break
conn.sendall(reply)
#came out of loop
conn.close()
#now keep talking with the client
while
1
:
#wait to accept a connection - blocking call
conn, addr
=
s.accept()
print
'Connected with '
+
addr[
0
]
+
':'
+
str
(addr[
1
])
#start new thread takes 1st argument as a function name to be run, second is the tuple of arguments to the function.
start_new_thread(clientthread ,(conn,))
s.close()