|
Ok, I am writing an xbox program that recieves a list of items from a PC application through a UDP socket connection. Each item of the list is sent separately. I have created this thread that constantly listens for the list. The problem is that when the list is longer than around 120 items I get this error: "[XONLINE] udpWarn: [D00212C8] Receive buffer is full (16466 bytes). UDP packet plus 3 data bytes lost." I know that UDP is not very reliable but when the list is say 100 items I have never had it drop a packet.
<br />
#define MAXBUFLEN 1000<br />
DWORD __stdcall ListenerThread( void* listen )<br />
{<br />
WSADATA WsaData;<br />
int iResult = WSAStartup( MAKEWORD(2,2), &WsaData );<br />
if( iResult != NO_ERROR )<br />
Debug("Error at WSAStartup");<br />
<br />
int sockfd;<br />
struct sockaddr_in my_addr;
struct sockaddr_in their_addr;
int addr_len, numbytes;<br />
<br />
if ((sockfd = socket(AF_INET, SOCK_DGRAM, 0)) == -1)<br />
Debug("Socket Creation Error");<br />
<br />
my_addr.sin_family = AF_INET;
my_addr.sin_port = htons(8604);
my_addr.sin_addr.s_addr = INADDR_ANY;
memset(&(my_addr.sin_zero), '\0', 8);
<br />
if (bind(sockfd, (struct sockaddr *)&my_addr, sizeof(struct sockaddr)) == -1)<br />
Debug("Bind Error");<br />
<br />
addr_len = sizeof(struct sockaddr);<br />
char* xrec = (char*)malloc(MAXBUFLEN);<br />
while(true)<br />
{<br />
if ((numbytes=recvfrom(sockfd, xrec, MAXBUFLEN-1, 0, (struct sockaddr *)&their_addr, &addr_len)) == -1)<br />
Debug("Recieve Error");<br />
xrec[numbytes] = '\0';<br />
}<br />
<br />
return 0;<br />
}<br />
|
|
|
|
|
Well, after several days of trying to figure this out I have come to realize that this code is just fine. The problem was the default buffer size on the xbox. I hope someone can at least find this useful. The paramater: cfgSockDefaultRecvBufsizeInK was the problem because by default it is set to 16K so I upped it to 64 just to be safe. Now everything works well.
|
|
|
|
|
Hi people i need some help on creating Digital Circuit
1st: How to implement the logic Results of the truth table of each gate using MFC/C++ programming.
Any demo sample codes would be helpful thanks
|
|
|
|
|
With logic operators. Are you using managed C++, or asking in the wrong forum ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
No i am using C++ combining with MFC Programming, i do not know whether this is a managed C++ thingy.
Jingpo
|
|
|
|
|
Then why are you asking in the managed C++ forum ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
How can I dock a form on a desktop (like taskbar)? I ve tried with the Dock property but nothing happens.
--Nikola--
modified 7-Dec-20 21:01pm.
|
|
|
|
|
Try in the C++ forum.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I wana help to develop a disk imaging utility . Any body which can guide me, will be welcomed.
Thanx in advance
MSIRAVIAN
|
|
|
|
|
Hello,
I keep getting a
error C2451: conditional expression of type 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' is illegal
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
at the spot marked below. I'm so confused... it looks like it should do what I want. Anyone confronted this before?
from main():
...
packetCount = fillPackets(inputString);
cout << "Filled " << packetCount << " packets." << endl;
...
int fillPackets(string inputString) {
string aPacket;
int packetCount = 0;
int x = 0;
cout << "Filling packets...";
while (aPacket = getNextPacket(inputString)) { <code><-- ERROR!</code>
packets[x++] = new packet(aPacket);
packetCount++;
}
cout << "done." << endl;
return packetCount;
}
string getNextPacket(string packetString) {
string aPacket;
static string::const_iterator theIterator = packetString.begin();
int start = 0, end = 0;
while (theIterator != packetString.end() &&
*theIterator != (char) 0 &&
*(theIterator + 1) != (char) 0 &&
*(theIterator + 2) != (char) 0 &&
*(theIterator + 3) == (char) 0 &&
*(theIterator + 4) != (char) 0 &&
*(theIterator + 5) != (char) 0 &&
*(theIterator + 6) != (char) 0) {
++theIterator;
start++;
}
if (theIterator == packetString.end())
return NULL;
theIterator += 7;
start += 7;
while (theIterator != packetString.end() &&
*theIterator != (char) 0 &&
*(theIterator + 1) != (char) 0 &&
*(theIterator + 2) != (char) 0 &&
*(theIterator + 3) == (char) 0 &&
*(theIterator + 4) != (char) 0 &&
*(theIterator + 5) != (char) 0 &&
*(theIterator + 6) != (char) 0) {
++theIterator;
end++;
}
if (theIterator == packetString.end())
return NULL;
aPacket = packetString.substr(start, end);
return aPacket;
}
|
|
|
|
|
Hello, Does Any one know how to create a movie file AVI or MPEG from JPEG or BMP file. I need to create an app that can read images from a directory and create a movie file from that? Please.... any help or pointers in the right directions
|
|
|
|
|
You need it in managed C++ ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I would prefer it in managed c++ or c#, failing that c/c++ would also be ok
do you have any tips/ideas/solutions?
|
|
|
|
|
I asked because most posts here are not for MC++ problems. I *think* DirectShow will do what you want, I looked into it ages ago. I'd recommend using C#, it's easier, and the underlying implimentation is going to do most of the work anyhow, so speed will not differ that much.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Dear All, does anyone have UDP socket sample code that can be send to me?. I need a code to tackle these questions:
a) Write and send a programme to send a single datagram.
b) a program to receive the datagram sent by the program (a above)
c) A program to wait for the reply from b above (question b)
d) A way of timing how long it takes for a datagram to get from the first program to the second and back again, i.e measuring the RTT of a datagram.
My email address is: jee_3000@yahoo.co.uk
Thank you for looking into this.
Regards.
|
|
|
|
|
|
I have a simple default C++ web service created with the wizards in Visual Studio .NET 2003:
#include "stdafx.h"
#include "blipwebClass.h"
#include "Global.asax.h"
#using <mscorlib.dll>
#using "BLIPSVRLib.dll"
using namespace BLIPSVR;
namespace blipweb
{
String __gc* blipwebClass::HelloWorld()
{
Interop::BLIPSVRLib::BlipClass *p = new Interop::BLIPSVRLib::BlipClass();
return(p->Puke());
}
};
I have added a reference to a simple ATL COM server I created with Visual Studio C++ 6.0 SP5 that exposes the BlipClass object and the method called 'Puke'. The minute you click the invoke button on the web service page, the page fails to come up and displays error 500 in the browser. If I do this from a Managed C++ console app, creating BlipClass and calling its Puke method works perfectly. Also, if I create a C# web service and add a reference to the BLIPSVRLib, creating the BlipClass object and calling its Puke method works perfectly. Why doesn't it work in a Managed C++ web service? Uggg!
Thanks in advance for any help,
Chris Disdero
Everett, WA USA
|
|
|
|
|
Hi!
System specs:
Language: C++
Compiler: Borland C++ 5.6 for Win32
OS: Windows Xp
App type: Console based application
I'm coding a Process-Lister program, where I try to output the DLLpath, ImagePathname and other strings gathered from the PEB block of each process..
This is (roughly) done in the way:
1) Read the start address of the RTL_USER_PROCESS_PARAMETER (RUPB*) from the PEB block. (offset = 0x010).
2) Read the UNICODE_STRING (US*) structure from the RUPB block (offset = depending on which field, ex: DLLPath = 0x030).
3) Read the Wide-character-string (UNICODE_STRING:Buffer) from the US block, (offset = 0x04), with the length (UNICODE_STRING:Length) bytes.
After this, I convert the read wide-character-string to a multibyte-string using the function WideCharToMultiByte.
Then I output it to the console using printf("%s\t",string)
The result is a lot of gibberish and makes no sense, I have tried changing the CodePage Identifier several times to several different types..
And still the problem remains...
Can someone help me? Or explain why? Iv'e been stuck with this problem for days now... And It's really getting to me..
See code below..
The following code demonstrates how I try to get the text from the UNICODE_STRING structure in the memory.....
<<-----CODE
.
.
UNICODE_STRING buff;
DWORD read;
if(ReadProcessMemory(process, (void *) address, &buff, 8, &read) == 0)
return;
if(buff.Length == 0)
return;
int str_size = buff.Length;
wchar_t *wchar_str = new wchar_t[str_size];
if(ReadProcessMemory(process, (void *) (address+4), wchar_str, str_size, &read) == 0){
RAP_ERROR(read);
return;
}
unsigned int codePage = 28591 //IS0-8859-1
unsigned int flag = 0;
int needed_for_trans = WideCharToMultiByte(codePage,flag, (LPCWSTR) wchar_str,-1,NULL,0,NULL,NULL);
char *multi_str = (char *)malloc(needed_for_trans);
int transed_bytes = 0;
if( (transed_bytes = WideCharToMultiByte(codePage, flag, (LPCWSTR) wchar_str, -1, multi_str, needed_for_trans, NULL, NULL)) == 0)
RAP_ERROR(read);
cout << "#DATA:";
int s = printf("%s\t", multi_str);
cout << "S:" << s << "\t";
cout << "¤BYTE:" << "[" << read << " | " << transed_bytes << endl;
delete[] wchar_str;
free(multi_str);
.
.
<<----------------------------------------------------
There is the critical piece ....
Now,, I would be REALLY glad if someone would help me....
The output from the printf is real gibberish....
And I don't understand why??
Thanks/ Gianfranco Alongi
/zen
|
|
|
|
|
Problem solved!!!!!
Fix:
I was treating the (LPWSTR) Buffer member of the UNICODE_STRING structure
as the actuall String, instead of a pointer to the WSTR.
Thanx annyway!
|
|
|
|
|
Hello, I am currently working on a project that includes creating a Server and an Client Progam.
My compiler (Who hates me because I got for free out of a Library book) often gives me errors that I cannot fix, an example being an undefined reference to WSAstartup(). My question is, should I invest in a "real" compiler for probably around $700 or could someone please lend me a copy of their C++ header files for creating Windows Sockets. (If that is at all legal of course, I wouldn't know)
Side Note:
Yes, I have looked in the guides and tutorials on CodeProject and have found nothing that, even with my modification, will satisfy my compiler's needs.
|
|
|
|
|
*sigh*
1. the header files won't help you. Downloading the platform SDK probably will
2. this question is not pertinent to MC++, you're asking in the wrong forum.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
WSA socket functions are Micrisift specifics, and you will be certain to have an error if you call such functions through a compiler that don't know them at all.
installing the SDK might probably help you to fix these errors.
> why not developping your own compiler ?!
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Assignment
Write a program in C++ and WIN32 api to implement an unnamed pipe. program should contain two threads ("producer" and "consumer") communicating through a pipe which is implmented using an array having 10 entries( ie 0 to 9). access to the pipe should be synchronized using a semaohore implemented as a " class" .The "p" and "v" operations supported by the semaphore should be exucuted "ATOMICALLY" Which is enforced using WIN32 API functions (e.g the createsemaphore funtion).
NOTE The P and V are the only operations supported by the semaphore class.
The poducer thread gets an integer ( a single digi, 0.....9) from the user and enqueues it into the pipe . The consumer thread always dequeues the first number in the pipe toward the front of the pipe after an item has been deposited ( by the producer) or consumed ( by the consumer)
We should use another "class" (ie the pipe class) to implement the pipe supporting operations " enqueue", "dequeue" and "move". The fisrt two operations have to be synchronized using the semaphore shown above (operation"move " is not because it is invoked by the first two operatios which can directl acces the shared pipe)
Note that your pogram should also be able to take care of the conditions when the pipe is either empty or full.When the consumer thread detects an empty pipe ,it prints a message to the screen.similarl when the producer thread detects afull pipe ,it prints a message to the screen too.
Note also that you should alwas delay the consumer thread by three 3 seconds by inserting a "sleep3000)" (without qoutes ) function into the appropriate place in the consumer thread.
The producer thread shold also show the contents of the pipe after a number is enqueued .
The consumer shouls aslso show the contents of the pipe after a number is dequeued .
The following shows the scenario of running program, where user inputs are underlined
enter a number: 5the
contents of the pipe (from the producer):bbbbbbbbb5
enter a number:2
the contents of the pipe(from producer):bbbbbbbb25
the contents of the pipe (from consumer);bbbbbbbbb2
enter a number:7
the contents of the pipe (from producer):bbbbbbbb72
the contents of the pipe (from consumer):bbbbbbbbb7
enter a number:
the contents of a pipe ( from consumer):bbbbbbbbbb
... an empty pipe is detected (from consumer):\\\
..................
|
|
|
|
|
1. Welcome to the academic world. You have two options. Either pay someone to do your homework now, and for the rest of your academic career, then go back to flipping burgers ( seeing as you will have learned nothing ), or try to do your own homework and ask for help when you get stuck. If you decide to fail your course, I'll do this program for you for $50. My fee for the next one will be $100, and so on. If you decide to learn for yourself, I'll be happy to help for free. That means you try first, and ask SPECIFIC questions when you get stuck.
2. This is the Managed C++ forum. Nothing about this assignment looks to me like MC++
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Christian said:
"If you decide to fail your course, I'll do this program for you for $50. My fee for the next one will be $100, and so on."
Hey, you are cheap!
And I was ready to bill him my usual rate of $250/hour to do his assignment for him!
Christian also said:
"If you decide to learn for yourself, I'll be happy to help for free. That means you try first, and ask SPECIFIC questions when you get stuck."
Exactly! No problem giving specific help, if stuck. I used to tutor Comp Sci in college, as well as work in the computer lab as a lab assistent (that was many years ago), and many times I've had other students want me to do thier assignments for them. It they where truly stuck and did not know how to get started, I did not mind giving some hints to help get them on thier way, but I was not about to do thier homework for them.
|
|
|
|
|