I've been trying to put together an application to change channel on a
media streaming server. The server is able to issue IR commands to
its attached equipment using LIRC, with commands being issued by a
socket connection to TCP/8765.
I put together a basic Python app that issued a command, which worked
fine. I wanted to create a fairly simple web interface and so set
about producing a similar simple PHP application. I've had limited
success so far, with the media server rejecting the connections.
Unfortunately I have limited access to the OS of the media server - I
just know that it recognises the commands from the Python app and
rejects the PHP one. I need to submit the following string:
SEND_ONCE pace_stb_5 rm_power
My PHP app (with all error checking removed) is as follows:
<?php
error_reporting (E_ALL);
echo "<h2>TCP/IP Connection</h2>\n";
$service_port = '8765';
$address = '192.168.1.100' ;
$socket = socket_create(A F_INET, SOCK_STREAM, 0);
$result = socket_connect( $socket, $address, $service_port);
$out = '';
socket_send($so cket, 'SEND_ONCE pace_stb_5 rm_power\n',
strlen('SEND_ON CE pace_stb_5 rm_power\n'));
echo $result . "OK<br />";
$out = socket_read($so cket, 1024);
echo $out;
socket_close($s ocket);
?>
In case it's of use, my Python application is:
#!/usr/bin/python
import socket,string
def send_ir(host, port, command):
exterity=socket .socket(socket. AF_INET,socket. SOCK_STREAM)
exterity.connec t((host, port))
exterity.send(c ommand+"\n")
while 1:
response = exterity.recv(1 024)
if response.split( '\n')[-2] == "END":
return response.split( '\n')[1]
break
exterity-socket.close()
HOST = '192.168.1.100'
PORT = 8765
status = send_ir(HOST, PORT, 'SEND_ONCE pace_stb_5 rm_power')
print status
On the face of it it seems as though both apps are sending the same
string; however I'm wondering if they're submitting the strings in a
different way. Apologies if any of the above is vague; I'll happily
provide any additional information if needed!
Thanks in advance,
Chris 8 3306
Can2002 wrote:
I've been trying to put together an application to change channel on a
media streaming server. The server is able to issue IR commands to
its attached equipment using LIRC, with commands being issued by a
socket connection to TCP/8765.
I put together a basic Python app that issued a command, which worked
fine. I wanted to create a fairly simple web interface and so set
about producing a similar simple PHP application. I've had limited
success so far, with the media server rejecting the connections.
Unfortunately I have limited access to the OS of the media server - I
just know that it recognises the commands from the Python app and
rejects the PHP one. I need to submit the following string:
SEND_ONCE pace_stb_5 rm_power
My PHP app (with all error checking removed) is as follows:
<?php
error_reporting (E_ALL);
echo "<h2>TCP/IP Connection</h2>\n";
$service_port = '8765';
$address = '192.168.1.100' ;
$socket = socket_create(A F_INET, SOCK_STREAM, 0);
$result = socket_connect( $socket, $address, $service_port);
$out = '';
socket_send($so cket, 'SEND_ONCE pace_stb_5 rm_power\n',
strlen('SEND_ON CE pace_stb_5 rm_power\n'));
echo $result . "OK<br />";
$out = socket_read($so cket, 1024);
echo $out;
socket_close($s ocket);
?>
In case it's of use, my Python application is:
#!/usr/bin/python
import socket,string
def send_ir(host, port, command):
exterity=socket .socket(socket. AF_INET,socket. SOCK_STREAM)
exterity.connec t((host, port))
exterity.send(c ommand+"\n")
while 1:
response = exterity.recv(1 024)
if response.split( '\n')[-2] == "END":
return response.split( '\n')[1]
break
exterity-socket.close()
HOST = '192.168.1.100'
PORT = 8765
status = send_ir(HOST, PORT, 'SEND_ONCE pace_stb_5 rm_power')
print status
On the face of it it seems as though both apps are sending the same
string; however I'm wondering if they're submitting the strings in a
different way. Apologies if any of the above is vague; I'll happily
provide any additional information if needed!
Thanks in advance,
Chris
socket_send($so cket, 'SEND_ONCE pace_stb_5 rm_power\n',
You have the string in single quotes, so PHP sends the characters
backslash and en, instead of the newline character you want.
Try pulling the string in double quotes (in both places).
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
On 24 Oct, 18:59, Jerry Stuckle <jstuck...@attg lobal.netwrote:
You have the string in single quotes, so PHP sends the characters
backslash and en, instead of the newline character you want.
Try pulling the string in double quotes (in both places).
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstuck...@attgl obal.net
=============== ===
Hi Jerry,
Thanks for coming back to me. I had originally used double quotes,
but the PHP script seemd to hand (firefox just reported waiting for
server for many minutes). I was obviously have a bad 5 mins, as when
I re-read the section on single vs. double quotes I could work out
why...
I'll do some more experimentation .
Chris
On 24 Oct, 23:59, Can2002 <can2...@nospam mail.netwrote:
but the PHP script seemd to hand
Oops, should have been hang, not hand!
Chris
Can2002 wrote:
On 24 Oct, 23:59, Can2002 <can2...@nospam mail.netwrote:
>but the PHP script seemd to hand
Oops, should have been hang, not hand!
Chris
But that "seemd" is just dandy!
My lord what are we teaching the kids now a days!
--
Andrew DeFaria <http://defaria.com>
I know you may think you know what I said, but I'm not sure that you
realize that what you think I said is not really what I meant.
Can2002 wrote:
On 24 Oct, 18:59, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>You have the string in single quotes, so PHP sends the characters backslash and en, instead of the newline character you want.
Try pulling the string in double quotes (in both places).
-- ============== ==== Remove the "x" from my email address Jerry Stuckle JDS Computer Training Corp. jstuck...@attg lobal.net ============== ====
Hi Jerry,
Thanks for coming back to me. I had originally used double quotes,
but the PHP script seemd to hand (firefox just reported waiting for
server for many minutes). I was obviously have a bad 5 mins, as when
I re-read the section on single vs. double quotes I could work out
why...
I'll do some more experimentation .
Chris
Well, it sounds like you need to look at what's actually being
communicated. It could seem to hang of it's waiting for a response from
the remote device which doesn't come, for instance.
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
On 25 Oct, 13:56, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>
Well, it sounds like you need to look at what's actually being
communicated. It could seem to hang of it's waiting for a response from
the remote device which doesn't come, for instance.
Thanks again Jerry,
I did wonder that, which was what led me to try the single quotes. I
know the box responds after a newline, both from seeing the effect of
removing it from my python app or connecting via Telnet. Am I right
in thinking that echoing "\n" will result in a newline character being
sent?
Sorry if it sounds like a stupid question...
Chris
Can2002 wrote:
On 25 Oct, 13:56, Jerry Stuckle <jstuck...@attg lobal.netwrote:
>Well, it sounds like you need to look at what's actually being communicated . It could seem to hang of it's waiting for a response from the remote device which doesn't come, for instance.
Thanks again Jerry,
I did wonder that, which was what led me to try the single quotes. I
know the box responds after a newline, both from seeing the effect of
removing it from my python app or connecting via Telnet. Am I right
in thinking that echoing "\n" will result in a newline character being
sent?
Sorry if it sounds like a stupid question...
Chris
Chris,
Echoing a "\n" won't send it over the socket, but I don't think that's
what you mean.
Sending a "\n" over the socket should send a newline character. But is
your device expecting a new line (Unix style) or a cr/lf (Windows
style)? If the latter, try "\r\n".
--
=============== ===
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp. js*******@attgl obal.net
=============== ===
On Oct 26, 3:43 am, Jerry Stuckle <jstuck...@attg lobal.netwrote:
Echoing a "\n" won't send it over the socket, but I don't think that's
what you mean.
Sending a "\n" over the socket should send a newline character. But is
your device expecting a new line (Unix style) or a cr/lf (Windows
style)? If the latter, try "\r\n".
Hi Jerry,
Thanks for that and sorry for the delay in response. I'm not
completely sure, but the device is running an embedded version of
Linux with Busybox and LIRC, so I'd be surprised if it needed Windows-
style returns. I simply append "/n" in Python...
I've been distracted with other work in the last week, but I'll keep
looking.
Cheers,
Chris This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Tero Saarni |
last post by:
Hi,
I have several threads communicating with each other using events
stored in Queues. Threads block on Queue.get() until somebody
publishes an event in thread's event queue.
I need to add support for sockets to the system. Thread needs to
unblock when:
- there is socket ready to be read, or
|
by: Gonçalo Rodrigues |
last post by:
Hi,
I have a problem with threads and sockets. I'll try to describe the
problem in words with pseudo-code.
I've been working on a few classes to make it easier to work with
threads. This framework, let us call it that, consists in two parts.
The first part is just a basic thread class deriving from
threading.Thread with a few extra functionality that makes it easier
for a thread to spawn a new thread and "father it". Each of its
|
by: Matt Chaplain |
last post by:
Hi there.
I'm writing a program that uses the Telnet protocol over TCP/IP
sockets. Of course, that has no bearing here, so I'll rephrase that
in Standard C++ :)
In essense, I'm trying to manipulate a data stream by using a custom
streambuf, so that I can access this as "just another iostream".
Alas, this data stream has a couple of "interesting" properties:
|
by: Jeff Crouse |
last post by:
In my project, I have successfully opened a sock_stream style socket
connection between two processes and am trying to send 'buffer' to a
connected client, 'fd'.
The following code works just fine.
void Macsock::writeData(char *buffer, int fd)
{
char message = "This is a message from the front.";
if(write(fd, message, sizeof(message)) < 0 )
|
by: Abhishek |
last post by:
I have a problem transfering files using sockets from pocket pc(.net compact
c#) to desktop(not using .net just mfc and sockets 2 API). The socket
communication is not a issue and I am able to transfer data across.On the
serve I am using Socket 2 API (recv function to read bytes)and not using
..NET. I use FileStream to open the file on the pocket pc, then associate a
BinaryReader object with the stream and call ReadBytes to read all the...
| |
by: mrpolitics |
last post by:
So I'm working with PureIRCD (http://sourceforge.net/projects/pure-ircd)
and everything was fine untill yesterday when the server crashed. So I did
a cold restart and staretd the server back up now it's throwing this stream
of errors right away. DOes anyone have any idea what they mean. I havn't
changed the source at all since it was working (which was for four days).
Unhandled Exception: System.TypeInitializationException: The type...
|
by: Tim Wagaman |
last post by:
I an having issuses with a loop I am running to keep checking for
messages coming across our line.
The goal:
Listen for messages on port 5001 and print the messages into a text
file. The port must stay open at all times and only close if no
activity for 60 seconds.
The problem:
If I do a read on a networkstream and the connection is closed
|
by: Ryan Liu |
last post by:
Hi,
I have a 100 clients/ one server application, use ugly one thread pre client
approach. And both side user sync I/O.
I frequently see the error on server side(client side code is same, but I
don't see the error):
"System.IO.IOException: Unable to read data from the transport connection:A
blocking operation was interrupted by a call to WSACancelBlockingCall"
|
by: =?Utf-8?B?RGFydGgtQ3ot?= |
last post by:
Hi,
I'm beginner in Visual C++ so I want to ask you a question. And I'm not good
in English:D
So I have the program which communicates over sockets. The program has to
connect to the server and send and receive data. But when I start the
program, there is one Socketexception - something like the program is unable
to connect to the server or the server didn't answer...
I apologize for my English... Thank you for advice...
|
by: Krzysztof Retel |
last post by:
Hi guys,
I am struggling writing fast UDP server. It has to handle around 10000
UDP packets per second. I started building that with non blocking
socket and threads. Unfortunately my approach does not work at all.
I wrote a simple case test: client and server. The client sends 2200
packets within 0.137447118759 secs. The tcpdump received 2189 packets,
which is not bad at all.
But the server only handles 700 -- 870 packets, when it is...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |