/    Sign up×
Community /Pin to ProfileBookmark

I checked this forum for answers found a few but it doesnt work. I have a service running on a remote machine listening for tcp/ip connections. I want to connect to this service using sockets, this i can do, but the problem comes when i send data to the service. My service uses a readln function to get the data, php only has a write function for sockets. This means there is no carriage return. I aded a carraige return to the command im sending but the service still cant recognise it. Need help please.

[code=php]
$socket = socket_create(AF_INET,SOCK_STREAM,SOL_TCP);
$result = socket_connect($socket,’172.1.103.2′,6667);
$Str = ‘REL’.chr(13);
$bytes = socket_write($socket,$Str);
if ($bytes == 0)
echo(‘No data were sent’);
else
echo($bytes.’ bytes of data were sent’);
//$ret = Socket_read($socket,1024);
//echo $ret;
socket_close($socket);
[/code]

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogSep 19.2006 — Just to be sure: is the listener waiting for a "carriage return" or a "linefeed" (newline) character? (I would have thought the linefeed would be more likely, or possibly a CR/LF pair, but you don't often see things looking for just a CR.)
×

Success!

Help @kloon_za spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...