C++ :: Publish Data Over The Internet In Peer To Peer Style Communication?
Sep 24, 2012
I need to be able to publish data between multiple machines at remote locations. I have been able to send data between two machines on a network in the same room. However, how to begin with resolving IPs for machines on other networks that are miles away etc. I would assume the application would need to LISTEN & PUBLISH in order to achieve this?
I have also googled this, and can only seem to find C# examples, and they seem to be for data between remote computers on the same network... What I need is to be able to find some guidance on sending data between me and someone who I previously had no knowledge of. I know this must be possible due to the fact that p-2-p chat clients exist, and that p-2-p file sharing exists.
I'm trying to realize a hybrid peer to peer network into practice.While I do have theoretical knowledge about this matter, I lack practical knowledge. The solutions I thought of all feel like hacks to me, so I present this issue in order to receive feedback.Consider the given network-model below:
We thus have a set of clients (Bob, Alice, Frank) and a Server singleton.Assume that in the initial state, Server has no knowledge of the clients (their IP might chance),while all the clients do know the Server's IP (as it is static). Further we assumethe usage of IPv4.
In order for arbitrary client to discover other clients a query must occur to the server. This is straight-forward.For clients to be able to listen to eachother, a listening port is used, say 6700.Now for the two problems, and the solutions I thought of:
1. Intra-subnet communication Bob wants to communicate with Frank. As we are past the initialisation stage, all clients know eachother's IP addresses. The listening ports are known aswel (6700). (!!!)However as both clients are behind a router, NAT will most likely assign a different port.How is this port of the NAT table discovered?
My solution:Since all clients perform a query to the main server, the main server will receive a structure with ip-address and port to send a message back to. Assuming the client does not close the socket, this port will always be available for receiving packets, even from other clients?
I am aware TCP uses sequence numbers, and the receiving client might expect a certain number and not accept packets from other clients all together...
2. Inter-subnet communication Bob wants to communicate with Alice. Assume the issues of (1) are resolved, and NAT maps Alice's listening port of 6700 (internal) to 55555(external). Is Bob able to send a packet to 142.128.1.100:55555 and expect it to arrive at Alice (assuming reliable packet transfer)?
I sent 1preample and 4bytes in transmitting side , preample contains only 1 and 0 with 4milliseconds delay, each byte contains 8bits with 2milliseconds delay , if a bit contains 1 it will send 1millisecond high and 1millisecond low signal ,and if a bit contains 0 it will send 2millisecond continuous delay, I have a problem at receiving side how to capture and store the preample and 4byte values in a buffer , i am using ARM processor it will update every 5microsecond ..
I want to send data from a laptop (windows 7, processor 2.60GHz) to a desktop (windows xp, processor 3.10GHz) using serial communication (using a USB to RS232 convertor). The WriteFile function is able to send the data from the laptop (NumberOfBytesWritten is correct). But on the desktop side, ClearCommError detects no data in the read buffer.
This is the relevant code in my desktop:
while(1) { ClearCommError(hPort,&dwErrors,&commStatus); if (commStatus.cbInQue != 0) ReadFile(hPort,&data,1,&dwBytesRead,NULL); Sleep(10); }
The if condition is never satisfied. The baudrate and other parameters in the DCB struct are the same on both sides.
The same code works when I write and read in the same system by shorting the RX and TX pins in the RS232 connector.
i have given a project for currency conversion program with add,delete,search,display option. but i was thinking if it can update the currency rate from internet at beginning.
I am currently writing a small windos form app which relies on an internat connection.
The only issue I have is trying to find out how to force the app to reconnect if the internet drops out without the app crashing. From what I have read I could use "try and catch" but I am not sure how to do this.
The code I have so far is: for testing I am using [URL] as the web site target.
Basically i'm willing to create an application which could share Video,Mp3 Over the internet to my friends.
For suppose I'm hosting file on my PC, and i want to share "D" Drive to my friends but they aren't connected to my network locally. i want to share movies over the internet using a host and client application in c#.net.
the purpose of this application is very clear that that i want to share movies over the internet and they have to be able to watch movies on their PCs Except running my PC remotely.
Casting Pointers in C Programming. I don't want to move onto implicit casts until I have this down pat. I'm failing to understand how casting pointers works.
The line int *mnt = (int*)&flt; if I read this correctly passes the address of flt which has been converted to an int to the pointer mnt.
1 - When I output mnt I get a garbage value, probably because the address of flt is then converted to a pointer and passed onto mnt as a value and then reinterpreted as a memory address. (that is the first part I don't understand)
2 - - What exactly does the (int*) cast say? Does this mean that a pointer will be returned or an address will be returned. What does the fact that the * is inside the parenthesis mean?
Code: #include <iostream> using namespace std; int main() { float flt= 6.5; int *mnt = (int*)&flt; cout << mnt << endl; // outputs hex memory address cout << *mnt << endl; // outputs garbage value }
I have added sql browser & sql server in fire wall, and also enabled tcp port 1433 and udp port 1434. the above connection string works perfect when i run it in the server machine, but whenIi try to run it on other machines I am getting an error that server is not available or cannot find the specified server.. I desperately need to access my database through an url. ie., through internet..
I want to write a command line parsing library that is very flexible in terms of parsing style but I'm not able to design a mechanism that satisfies this requirements.
Generally i want to have a class that contains all the necessary information about how the command line has to be parsed.
Code: // draft class style { public: enum class type { // the basic style type
[Code] ....
Need completing the draft shown above, because for every basic style type there is an own set of extensions that applies only to this one specific style type.
Code: // how a style object should be created style parsing_style(style::type::posix, style::extension::gnu|style::extension::subcommand);
How to design the class. (using c++11 features like std::enable_if is fine)
I need to convert a string into a Font object. I'm trying to use the Font Converter but I don't see support for the font Style. I need to save a font to a string and back again using the font name, size and style.
Font font1 = (Font) converter.ConvertFromString("Arial, 12pt");
then the cstrp can be treated as cstra, and so I can also use
cin>>cstrp;
but when I write the following program, I find it don't work, don't have clue
#include <iostream> #include <string> #include <cstring> using namespace std; int main() { char cstr[5];
[Code] ....
for cstr, it work exactly as what I expected, but for cstrp, no matter what I input, with a null terminator or not, I just got nothing printed. why? can we really use cstrp in that way or not? How to use it?
I want to set font size and font color for button in MFC. But MFC differrent from win32. It have no font style in property. How to set font color and font size for button in MFC ?
I have to communicate between two laptops using USB-to-Serial adapter. I have written 2 programs one for sending and another for receiving. Programs were written in both C and C# programming languages.
Using C language: I am able to successfully communicate using C-Programs mentioned below. But the problem is speed. It takes around 1 hour(60min) for just to pass 150MB. improving the performance of this programs...I also mention some comments along with programs for self understanding.Sender File on laptop with serial port :
The above 4 programs behaves as, sender send a character and receives an ack for every character. I have followed this approach, bcoz other approaches were not working fine (in the sense the complete data is not sent, the amount of data sent is not judgeable, bcoz it will different every tym). when i used this approach it worked fine.
I am trying to read in data from a text file and store it inside a 3D array. The text file looks like this: bar bell orange bell bell 7 lemon cherry cherry
I can read in the data fine, but how to store it inside the array. My array looks like : [ Char slotMachine[10][3][8]; ] T
he dimensions are Row, Column, and symbol. There are 10 rows and 3 columns inside the file. The third dimension is supposed to hold the symbols as a C-style string.
This is what I have been trying:
char symbol[8]; int rowIndex = 0, colIndex = 0; While(fin.good()){ fin >> symbol; slotMachine[rowIndex][colIndex][] = symbol; rowIndex++; colIndex++; }
I know that i'm not storing the symbol right. How to correctly store it inside the third dimension.
Are there any good free or commercial software that can check the C++ code style and find any codelines that violate a given code style specification? For example, whether the codeline is indented proplery, whether the variable is using Hungarian naming notation?
I need to implement a two-way asynchronous communication between two objects, not using any IPC.
What I have now is a producer-consumer model where producer sends a number "88" to consumer at random intervals. Now, I need consumer to send a number "99" back to producer at a random intervals, this probably should be done in a separate thread.
I am using GNU on Linux, here is the compile line.
Code:
g++ -g -std=c++11 main.cpp -o main
Code:
#include<iostream> #include<chrono> #include<thread> class IObject { public: virtual void fromApp(int i) = 0; virtual int toApp(int& i) = 0;// ???