I would like my UDP server to send the data when the client connects; say at a rate of 100 msec.
But I can only get it working when the Server does a receive first (so the client has to do a send) then the Server does the send.
Can this be done? The server fails if I do not do the Receive and the client fails if I dont run the server first.
If I comment out the receive I get error 10057 on the send.
The error is WSAENOTCONN.
That's expected since you're using the "from" address from the recvfrom(),
which isn't going to be a valid address without a successful recvfrom() call.
I would like my UDP server to send the data when the client connects;
UDP is connectionless so you don't know if a client is connected or not.
It sounds like you need to either...
1) Keep track of clients that are listening - that would mean a client has to send a notification to
the server when it's ready to receive datagrams. The server can store a list of "connected" clients and
send the periodic datagrams to every address on the list.
2) Broadcast the periodic datagrams. Set the socket option SO_BROADCAST on the socket and send
to the broadcast address (INADDR_BROADCAST). The clients need to set the SO_BROADCAST socket option
I just want to Broadcast UDP packets out on a local network, what destination address do I use
You could use the limited broadcast address 255.255.255.255, however it is best to use the correct IP broadcast address of your local network segment (more successful in my own experience). You can calculate the correct broadcast address, see here.
Which kind of device are you communicating with ? USB doesn't work like a serial port: you don't have access directly to the port but instead you get the handle of a driver. This driver is shipped with the device you want to communicate with and manages all the communication with the device.
To get the handle of the driver, simply call CreateFile supplying the correct driver name, then you should be able to use ReadFile and WriteFile. You can also do some more specific stuff by calling DeviceIOControl (in which you can pass some specific IO code which is dependent of your driver).
So, if you want more help, you'll need to give a lot more information (which device do you try to access, if you have documentation with it, ...).
don't tell me that you don't find the way to implement the secant-method or bisection method!
You have only to implement the algorithm:
ask for a function f(x) and for the borders x1 and x2.
check that sign(f(x1)) != sign(f(x2)) .
Then compute x3 inside the interval (x1, x2). This according on the algorithm, in bisection case x3=(x1+x2)/2,....in secant method it's only the point where the line from (x1,f(x1)) to (x2,f(x2)) intercept the x-axe.
then choose the new interval (or x1-x3 or x3-x2) according on where is the root.
Then start again on the new interval.
Do this 10000...000 times and stop it. Or stop when the interval is "too small".
i have worked very enough with serial port(RS 232).
but never heard of the cts pin and dcb.
atleast for my information please educate me regarding those.
then i will try to solve if it in my perview.
I use PCOMM library for sending and receiving data using serial port.
functions are like
sio_ioctl(); to define the port settings.
soi_iqueue();to find weather any data is there in the port.
may be i can help you if you are also using these libraries and functions.