I am currently trying to send a x264 nal unit using WINSOCK with a reliable multicast socket. It isn't decoding properly, and my initial thought is I am not receiving all the bytes correctly. I was hoping some fresh eyes can provide insight on errors or any improvements. I have seen some topics about this subject, and they showed sending entire structs with the socket. However, I am concerned about endianess so I am trying to stay away from that approach. I have commented out the decoding part, until I am confident that I am receiving the nal unit properly.
send(s, content.c_str(), content.length(), 0); I'm executing the "dir" command to get a listing of Folders/files of one Folder. Then I read the Output of the file and send it over winsock to the Server.
Now, the Problem is, I don't know how I can handle the recv properly, cause I have to set the buffer size without knowing, how much data is actually transfered. Sometimes maybe no files are in c:filequeue, sometimes a 100k.
So I tried to make recv as a Loop:
Server:
Code: ...
while (rc != SOCKET_ERROR) { printf(" #"); gets(buf); //please no discussion about gets, I will Change this later ;) if (strcmp(buf, "ls") == 0){ send(connectedSocket, "LIST", 4, 0);
[Code] .....
now it works, but as the recv blocks, it will never leave the Loop, even when the Transfer is finished.What should I do?
I believe I could make unblocking sockets, but that's a bit complicated. Isn't there an easier solution, with malloc'ing the buffer or a Signal when to leave the recv Loop?
This question is kind of a continuation of Winsock Sending X264 Nal Unit. I was finally able to solve that problem, turns out in the end I was missing a memcpy(). Now my current issue is, when I try to decode the received packets, I am shown a bunch of errors. I have attached a picture with my decoding errors. So since I am using a reliable multicast socket, which doesn't guarantee order of delivery. My initial thought is that I am getting packets out of order.
So my question is, how would I attach a packet header to my current data? Could I get away with sending the header separately? Similar to what I am doing with the nal length. If I do attach my header to the packet data, what is a good way to delimit the two?
My client is just reading packets into a vector, because decoding it right away was too slow. So I thought that might have been an issue, so I decided to read in 200 packets just for testing purposes.
I'm trying to understand winsock with c++. Let's assume I have a 2 working applications, one is the client and one the server:
Client: I can enter a command, for example chat or filetransfer, it will then switch into this specific mode where I can enter commands like uploading a file, send a message etc.
Client Code: .... while (rc != SOCKET_ERROR) { printf(" #"); gets(buf); if (strcmp(buf, "CHAT") == 0){ // start chat mode
[Code] .....
I'm in a recv/send loop and I'm using streams...so basically all the data is being sent/received there. Now, if I want to upload a file, I send a FILETRANSFER String to the server. Then I will probably need another loop that receives file requests from the client. The server will need more details about the file, like the path, name, size...
Now, my question is, what's the best practise for something like that? I'm having problems understand how I can send 3 different values from the server to the client and how he will receive them in the right order store them in variables. And also, after sending something to the server, in some cases, the client will have to wait for the server to answer.
Code: #include <algorithm> #include <winsock.h> void some_func() { int result = std::min (0, 16384); }
Okay, but the above code consistently gives me error C2589: '(' : illegal token on right side of '::'. I'm building with VC8. If I don't #include <winsock.h> the code compiles correctly but it doesn't matter if I #include <winsock.h> before or after including <algorithm>
I guess it might be due to one of my #defines but I've tried the code in a very minimal program and I still get the error.
My problem is that I've created a Client and Server program in which they communicate. The Client is an SDL Application that allows you to play as a movable character IF YOU ARE CONNECTED TO THE SERVER. If not, You're unable to play. THIS WORKS!
However, Only one client is able to play on my server?? Anyone elses' window freezes and they are not allowed to play (As if not connected to the server). Here is my server code.
In my UOW class I have the public property ProductRepository. Now my idea was instead of creating a public property for every repository that I have, I created the generic method GetRepository<T> to dynamically create repositories.
Do you think that this change will have bad side effects. I think that it will improve the maintainability of the code.
Code: //needs to copy it so that if its a function call it only does it once #define assertNAN(type, one) { type val = (type)one; std::string lag(#one); lag += " not a number";
[Code] ...
I am compiling with -DNDEBUG -O3 -ffast-math -fexpensive-optimizations to simulate a production environment. Is there a way to test for NAN consistently?
I have function that returns historical data. I can access it, using file name. If I use file name, it reads that file and saves it to dictionary, so that in the future, if historical data is required for the same file, it does not read it again (it's lazy loading). If no file is supplied to the function, it tries to read file which is given in app settings.
However, for unit testing, I do not want to read any file. Instead, I want it to use small sample of hardcoded historical data. In order to do that, I think, I need to introduce interface to it. Then I can use some IoC to choose between different implementation for unit testing purpose and ordinary launch of application.
Function to get history is given as follows:
public static class Auxiliary { private static Dictionary<string, MyData> _myData; public static MyData GetData(string fileName = null) { // ... } }
I have created default Unit Test project with Visual Studio so, as far as I know, by default it uses MSTest as test runner and MSUnit as unit testing framework but it does not have any IoC container so I should manage NuGet packages for solution and install Unity.
As far as I know, MSUnit (aka Moles) can unit test static methods (it's unconstrained isolation framework, like Typemock Isolator, unlike NUnit) but still many people suggest not to use any static methods for unit testing.
Should I use shim or stub [URL] Stubs should be used for faking external dependencies and here it is not external library, but my own code.
I'm new to c++ and boost library also. I need to test a function of my library. For example
// Functions.hpp int add(const int x, const int y); //Functions.cpp int add(const int x, const int y) { return (x + y); }
Now i need to test add function using boost. I need the result or output in below style. What all settings do i need to do in VS 2010 and how i should include boost test in the project.
==== Run unit tests ==== Running 2 test cases... ./mytest.cpp(13): error in "SimpleTestInMainTestingModule": check 1 == 2 failed Test suite "Master Test Suite" failed with: 1 assertion out of 2 passed 1 assertion out of 2 failed 1 test case out of 2 passed 1 test case out of 2 failed
I am trying to write a unit convertor for converting temperatures Celsius, Kelvin and Fahrenheit.
Code: if (select_one == 't' || select_one == 'T'){// this one works perfectly... //This section does not tell you the use of variables. //The use of variables can be seen as comments in the main program
[Code].....
This part of code will be part of a larger Unit Converter program. Do you think this method of conversion is wise? The error codes are for debugging use only.
I convert all temperatures of all units, whether Celsius, Kelvin or Farhenheit into Celsius and then convert it into the units the user wants.
I need to sort this and I know how to do it. But I need to sort it again with the highest value in the first row and keep all information in that row paired with the name . So
Lincoln 120 300 400 Parks 100 500 250
Parks 100 500 250 Lincoln 120 300 400
I need so swap this whole rows. I'm using dynamic array. So my question is Do I have to do a bunch of temps to move them? Or is there a way to move the whole int array row as a single unit?
I have a socket connection already set up, my thing is what would be the best way to send a packet through sockets? My teacher wants us to convert the packet to bits first before we send it. I think he wants something like this:
Code: struct packet{
int header int message int flag
}clientpacket; m
My question is how do we covert this to bits, before sending it. One of my friends said we can create a char[] array the size of the struct as a buffer. will memcpy() change the struct to bits if I copy it to the buffer?
this is how is suppose to look in bits for the header field/column.
Field : header Field size(bits): 8 data format: Unsigned int value example: 1 Value in bits: 0000 0001
I am confused, I think I send a structure over the socket but I did not convert it to bits before I sent it .
I want to write a program(s) so that the client sits and waits for a scanf to receive an int, then send to server, server then receives the int, processes it, then goes back to sit and wait for new input. to start with, where do i start! server side, or client side? and also what order do i have to go in my program before the loop to set up the socket, and listen? and then what gets looped to keep the connection open and wait for new receive?