473,465 Members | 1,373 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

fsocket(<udp:host>,<port>) Not working, no errors reported.

dlite922
1,584 Recognized Expert Top Contributor
Hello Hello!

I'm trying to connect to a host that accepts UDP on a port I setup and tested from a command line too called udp_write. However a PHP fsocketopen() call doesn't work nor does it give an error.

stripped down code + fake data:

Expand|Select|Wrap|Line Numbers
  1.  
  2. $fp = fsockopen("udp://999.999.999.999",9999,$errNo,$errMsg) or die("$errNo : $errMsg");
  3. $test = fwrite($fp, "Logging Test"); 
  4. print($test); 
  5.  
  6.  
var_dump() of $fp says its a socket resource and print($test) gives me an integer < 100. (ie. 12)

Do you see an issue with this code? I can connect from this host to the target host from the command line with this UDP port.

Let me know if I'm missing something,

Cheers,




Dan
Apr 2 '09 #1
2 2246
hoopy
88 New Member
Hi Dan,

This piece from PHP.net explains the lack of errors with UDP:

Warning

UDP sockets will sometimes appear to have opened without an error, even if the remote host is unreachable. The error will only become apparent when you read or write data to/from the socket. The reason for this is because UDP is a "connectionless" protocol, which means that the operating system does not try to establish a link for the socket until it actually needs to send or receive data.
fwrite returns the number of bytes which have been wrote so it should be working. Can you explain what data you are sending and what result you are expecting?
Apr 3 '09 #2
dlite922
1,584 Recognized Expert Top Contributor
@hoopy
This code will be used to send log messages to a logger server. Each application in the environment (including mine) has been setup to send string text to that server. The logger software there adds a time-stamp and formats it into a .log file for troubleshooting and monitoring purposes.

I did see that note (in fact I've read everything in the manual, as I always do so I don't come here and sound like an idiot :D )

However, i thought I'd get some error when I tried to write, hence why I dumped the output of fwrite().

That is the byte written your right. So I'm thinking the problem is not in the code and maybe elsewhere.

I'll post back a solution if it's related to the code.


Thank you,




Dan
Apr 3 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Krister Liljedahl | last post by:
Hi, I'm getting an "10055, An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full" error message when opening 64 or more...
24
by: Massimo Soricetti | last post by:
Hello, I'm not a C newbie, but I'm teaching C programming (well... FIRST programming and then C) to other guys these days and it's driving me to some reflexions on the language. It's not...
4
by: Allthumbs | last post by:
Hi, Both laptops seem to have the same set up office 2002 and windows XP. But copyfromrecordset works fine on one PC and fails in another. It does not throw any exception. Help!! thanks,
0
by: John Oliver | last post by:
I'm having a devil of a time with phpBT. It displays nothing but a blank screen. I'm trying to get some kind of indication of what's going on, but am having no luck whatsoever. I've tried: ...
13
by: kolmogolov | last post by:
/* Hi, I have removed things irrelevant to reproducing the problem. What's wrong with my code? Thanks in advance for any hint! 1166425362 */ #include <stdio.h> #include <stdlib.h> #include...
2
by: shk253 | last post by:
Hi all - The following is the code for one of my functions in a program but the compiler is reporting errors. I've also tried declaring the variable temp within the function but the number of errors...
3
by: r_ahimsa_m | last post by:
Hello, I am learning JavaScipt. I have written some functions and I verified my code using http://www.jslint.com/ validator. I don't understand the problems it reports. Could you help me please...
88
by: Bill Cunningham | last post by:
Would anyone be interested in giving this a quick look. The compiler gave me so many errors I don't know where to start. This is my first use of isalpha. #include <stdio.h> #include <stdlib.h>...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
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 ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.