I have a simple UDP client that should be able to send and receive packets. It does its job, however if there are no packets received for a while it stops listening for any new packets and I'm not sure what's causing it.
I'm building a client server which is communicating.I am trying to use the function recvfrom, but have several bugs, so I might have the recvfrom function in the wrong part of my code.
Code:
int talk_with_server(int fd) { printf("Test. "); char buf[LEN]; int n = read(fd, buf, LEN);
I am trying to make kind of a messenger using Socket/Network Programming
My program should allow clients to register or sign in, after they are signed in they should see a list of the other signed in people whoever I select from that list I should be able to implement using multiple threads as well.
I'm trying to get a UDP server working and just can't seem to get it to read in any UDP packets. I can see the packet coming in on the correct interface and port from tcpdump, but my program never logs that it got the data.
I just keep getting a log showing that my recvfrom timed out. I'm pretty sure I'm setting everything up correctly.
I have to write a program to take packets of information destined for certain ports then provide the current message using the packets I've gotten so far. Packets can come out of order, so when asked for the message, packets that haven't arrived yet are skipped and the next packet is appended. After giving the message, I have to delete all the current packets as well as ones that are received late, after the packets that were supposed come after the late packet were already provided in the message.
Data:Up to 1000 ports, numbered 0-64000, and each message can contain up to 1000 packets.
I captured packet that is sended to server then that button is clicked
POST (info hided)/amfgateway.php HTTP/1.1Host: (info hided) Connection: keep-alive Content-Length: 52
[Code].....
It apears that this is AMF(Action Message Format) type packet Content-Type: application/x-amf it is in binary and this complicates things a little because I cannot send it with regular httpwebreqeuest class(Or I think so)
I used Fiddler4 with AMF plugin to check what data was passed with that packet
It apears that these numbers under content / 0 are User-id that is needed to add user to friends
I did a research with little success finding any usefull examples. I just found that there is a library for FLEX/FLASH remoting called fluorinefx and this should do the job but when I opened documentation it seems little too complex for me.
Here are the segments of me trying to push the packets onto a vector:
[code] std::vector<size_t> processing_queue; //HERE IS WHERE I'M TRYING TO PUSH THE PACKETS ONTO A VECTOR processing_queue.push_back(num_rx_samps); [code]
I previously had my program saving to a .dat file (the commented out lines), but I need to change it to pushing values onto a vector so I can stream the data packets from the ethernet cable to be processed. However, the packets aren't being pushed onto the stack as I suspected. What do I need to change to push the data packets onto a vector? The following is the code:
I have a requirement to sniff the wifi packets. There are examples available which does the sniffing using pcap functionality. I need a C program which will sniff the wifi packets without using pcap functionality..
Code:
#include<pcap.h> #include<stdio.h> #include<stdlib.h> // for exit()
for (int i=0; i<nrolls; ++i){ int number = distribution(generator); cout<<number<<" "<<endl; }
(original code: [URL] ... )
This outputs: 2 3 1 4 3 4 4 3 2 3 and so on... First of all what those numbers mean? I mean do I have to sum them to create timing? For example: 2, (2+3)=5, (5+1)=6, (6+4)=10,..., and so on..
Secondly, my real question is, I need to produce both random arrivals for network packets and the size of packets. I mean, when the packets come and if packets come, what are the size of packets? How can I do that? I need something like that: [URL] ...
std::vector<size_t> processing_queue; //HERE IS WHERE I'M TRYING TO PUSH THE PACKETS ONTO A VECTOR processing_queue.push_back(num_rx_samps);
I previously had my program saving to a .dat file (the commented out lines), but I'm trying to change it to pushing values onto a vector so I can stream the data packets from the ethernet cable to be processed. However, I'm having issues with pushing the data packets onto the vector?
If I have a text file named, stuff at a specified path in the c : drive, how do I send the contents of this file to another computer using the Internet?
I want to receive an information from a file. For instance, you created a file name "sample.txt" via fstream and stored a bunch of people's name, address, phone number in that "sample.txt".
Now, I want to see what's stored in this file. Suppose, I wanted some particular guys address, phone number by just typing is his/her name.
How to relate the name with address and phone number of particular people? I just started the file creating so I wanted to know about it.
#include<iostream> #include<conio.h> #include<fstream> #include<string> using namespace std; int main() { ofstream outputData;
My program works primarily by receiving user input however; using 'char' and 'fgets' i have to stipulate how many characters i want assigned, and this isn't practical for what I am after. Example below.
Code:
char example[50]; printf("What colour is the sky? "); fgets(example, 50, stdin); Is it possible that the assigned number (in this case '50') is determined strictly by the user input?
for example, user input is Blue then 50 is then 5?
I want to calculate the total some of delay pf receiving Side Packet . Code is as Follow ..
What is weird that even if i invoke a sleep of 2 sec ,than its show delay always zero. Delay will be in microsec ..Is there any problem with logic or anything else..
Code:
do {#pragma omp parallel private(nthreads, tid) { /* Obtain thread number */ tid = omp_get_thread_num(); if (tid == 0) { nthreads = omp_get_num_threads();
I am doing a project where i need to develop a C# windows application. I need to receive data in my laptop (windows 7) using BLED 112 Dongle from NRF 8001 which is Bluetooth Low Power. Actually NRF 8001 is connected to a sensor and it is streaming the sensor's data. I need to receive those data using Dongle and save those data.
I tried doing this by using the library provided by 32feet.net but using this i could only discover the device but wasn't able to connect my Dongle to NRF 8001. So i couldn't proceed further and i am stuck since couple of weeks already ....
I already tried searching in the internet but didn't find much info however i recently i got a API for my Dongle in this link
I'm trying to write a program that passes Windows messages back and forth from another program that controls a laboratory instrument. I was able to write a program that successfully passes instructions, as evidenced by the instrument doing what I tell it. However, I am having trouble getting a return status from the instrument. The manual instructs the following:
// demo code, etc. // send message to the instrument operating software here... SendMessage(hwnd, WM_COPYDATA, tag, (LPARAM) &cd)
Either a completion message or return data is returned. Remote commands ReturnStatus, ReturnTiming, and ReturnData return data. In either case, data is received through an asynchronous windows message inside Win32 COPYDATASTRUCT type data packet.For example, a typical OnCopyData window callback is shown below, where the string data retrieved is finally stored into a Microsoft CString object. Note the use of variable replyTag, discussed above, which is used to isolate the correct windows message returned.
BOOL CUserDlg::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* cd) { …. if (cd->dwData == replyTag) { /* String pointing to status */ CString retStatus = (char*) cd->lpData; } …. }
I can't tell if my problem is in generating the replyTag, getting the HWND to my own console window, or the actual receiving part of the code.
When setting the replyTag, the manual instructs: UINT replyTag = RegisterWindowMessage(“SOFTMaxProReplyMsg”);. However, I have to put an "L" in front of the string or I get a data type error (can't convert const char* to LPCWSTR).
When setting a HWND for myself, the manual instructs: HWND MyWnd = GetSafeHwnd().
That produces an error because GetSafeHwnd is a function of the Cwnd class, and I don't have a Cwnd. I have replaced it with HWND MyWnd = GetConsoleWindow();
When listening for the reply message, the manual instructs what I quoted above. However, I again don't have a Cwnd. I therefore simply used
The above if statement always evaluates false, and the cd.lpdata contains the message that I had sent out instead of a reply message. How to get a reply using my console application. Here is the full code of my function:
Code: #include "stdafx.h" #include<iostream> #include<vector> #include<string> #include<afxwin.h> using namespace std; void SendCommand(string command) { // Get tags to identify the receiving and sending messages
I've created a new dialog in my MFC dialog based application. the new dialog contains 5 control buttons. The following happens and I don't understand why?
1. click on buttonX. (result ok, OnBnClicked message is sent) 2. click on on any place of the application, but not on the dialog.(removing focus from dialog) 3. click again on buttonX (FAILED, OnBnClicked message is NOT sent). but if instead I click on any other button in the dialog (result ok, OnBnClicked message is sent).
And when I do:
1. ... 2. ... 3. click on the dialog area just to set focus on the dialog again 4. click again on buttonX. (result ok, OnBnClicked message is sent) **I need to do step 3 only if I want to click again on the buttonX! why?? I think it related to SetFocus() but I m not sure how.
I've tried different style like, tool windows, overlapped, popup. it happens in all the cases.
Code: class CToolsDlg : public CBDialog { DECLARE_DYNAMIC(CToolsDlg) public: CToolsDlg(CWnd* pParent = NULL); // standard constructor virtual ~CToolsDlg(); CToolTipCtrl m_ToolsTips;
I wrote this simplified version of a program i am writing that parses data in UDP packets. In the process of doing so i pretty much answered all my questions and fix all the problems i was having.
decodeSystemMap function will be in loop, and will proccess packets that have mostly the same data, only a few items will be added or changed or deleted.
whats the best way to check if there are any new, deleted, or removed items in the packet and only modify those? Is there anything unsafe / dangrous about the way the code is now?
Code: /* * File: main.c * Author: david * * Created on May 23, 2013, 11:57 AM */
I need to create a client and server program. The client will have a GUI that will display all the available servers (since more than one will be running) in a list box.
I’m guessing a TCP connection will be the best method here, but how will the client find the servers to connect to? I won’t know the IP address of the server because anyone could take the server program and run it on their computer and the client would have to find it.
Is there some way to make the server send some kind of signal that only the client application will be to connect to? So the server will be sending out a signal, the client finds the signal and connects to the server. Is this possible?
i also need to be able to store the IP address the client selects so when the client application is run again it will automatically connect to the server that was stored.
So I have been working on a general class for our department to send errors to us when they trigger. We changed over to the Office365 Cloud System and now I am having Authentication Errors with my emails. Here is the code:
public static void ErrorDev(string errorText) { try {
I have to make a server-client file transfer using UDP . I have created a basic server which receives message sent by client . That's all. Now comes the major part :-
1. The message sent by client is the name of file .2. Now the server checks whether there exists this file or not . 3. If there exists it sends the file to the client and it also keeps the count of the number of requests of file made by the client . Here is the Server Code
The server reads the data from file and writes into it and send to the client , On the other end client receive the data and make duplicate of this file and write into it. But on compiling it gives error in reading the file.