Sub Process_Globals ' code is inside a service
Private RemoteCaller As AsyncStreamsText
Private SendPhoto As AsyncStreamsObject
Dim ServerS As ServerSocket
Dim nPort As Int : nPort=10250
End Sub
Sub Service_Create
ServerS.Initialize(nPort,"ServerEvents")
End Sub
Sub Service_Start (StartingIntent As Intent)
MyIp=ServerS.GetMyIP
ServerS.Listen
End Sub
Sub ServerEvents_NewConnection (Successful As Boolean, NewSocket As Socket)
If Successful Then
RemoteCaller.Initialize(Me, "Server",NewSocket.InputStream,NewSocket.OutputStream) ' strings I/O
SendPhoto.Initialize(Me,"Image") ' for sending picture
SendPhoto.Start(NewSocket.InputStream,NewSocket.OutputStream)
Else
Msgbox(LastException.Message, "Error connecting")
End If
'ServerS.Listen ' don't need continue listening to new incoming connections
End Sub