|
forget the error, that was something else, this works, thank you so much!!!!!!!
|
|
|
|
|
Hi! I have visited so many WinSock tutorials to find source code that works, but it never does! All i want to do is to get 2 computers on my network to exchange data! That's it! From what i've read about WinSock, it should be able to do that without any problems. I either can't get it to compile, or it refuses to communicate to any other computers outside my own. I just don't get it! Are there any tutorials or source code that actually works? An MFC tutorial would be OK too.
-- Steve
|
|
|
|
|
Do you read the full article or just download the source code. There are plenty of winsock example on CP that work, but sometimes you have to read the article so you know what to trouble shoot
Matt Newman Sonork: 100:11179
"Whoa, that ruled! What function key do I gotta press to get that to happen again?" - Strong Bad
|
|
|
|
|
VERY TRUE.
<marquee>Universal Project
|
|
|
|
|
Hi,
I've been trying to implement a simple server using AcceptEx(). However, no matter how I create the listening socket, AcceptEx() always returns 0 with error code 10022.
10022 -> An invalid argument was supplied.
Here is a quick example.
-----
SOCKET listeningSocket = ::WSASocket(AF_INET, SOCK_STREAM,
IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED);
u_long host;
::WSAHtonl(listeningSocket, INADDR_ANY, &host);
SOCKADDR_STORAGE listenAddr;
SOCKADDR_IN *pListenAddrIN = reinterpret_cast<sockaddr_in
*="">(&listenAddr);
pListenAddrIN->sin_addr.s_addr = host;
pListenAddrIN->sin_family = AF_INET;
u_short port = 0;
::WSAHtons(listeningSocket, static_cast<u_short>
(21), &port);
pListenAddrIN->sin_port = port;
::bind(listeningSocket, reinterpret_cast<sockaddr *="">
(&listenAddr), sizeof(SOCKADDR));
::listen(listeningSocket, 2);
// AcceptEx()
SOCKET acceptSocket = ::WSASocket(AF_INET, SOCK_STREAM,
IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED);
WSAOVERLAPPED ol;
memset(&ol, 0, sizeof(WSAOVERLAPPED));
char buffer[4096];
unsigned int nSASize = sizeof(SOCKADDR_STORAGE);
::AcceptEx(listeningSocket, activeSocket, buffer,
4096 - ((nSASize + 16) * 2), nSASize + 16, nSASize + 16,
&nReturn, &ol);
DWORD error = ::WSAGetLastError();
-----
In the example above, the call to AcceptEx() returns
error 10022.
Please post if you see what the problem might be.
Thanks,
Kuphryn
|
|
|
|
|
Is it possible to progmatically change the IP address of a specified network adapter. I'd like to avoid changing registry settings. Also is it possible to switch from DHCP to Static?
Matt Newman Sonork: 100:11179
"Whoa, that ruled! What function key do I gotta press to get that to happen again?" - Strong Bad
|
|
|
|
|
Ehem I don't know a whole lot about TCP/IP programming but I 'think' that you can't change it and probably that may be the truest thing but are there any other 'opinions' out there?? And anyways why would you want to change the IP... suspicious wink;)
<marquee>Universal Project
|
|
|
|
|
snyp wrote:
And anyways why would you want to change the IP
Because this computer is used on 2 different networks that use different IP ranges.
Matt Newman Sonork: 100:11179
"Whoa, that ruled! What function key do I gotta press to get that to happen again?" - Strong Bad
|
|
|
|
|
I guess you cannot change it progmatically. Maybe someone else would explain it better to you cause I'm not the most knowledgable person out there in the network thing. (getting into databases right now and probably later into networks)
<marquee>Universal Project
|
|
|
|
|
I don't think it is possible when you are already connected... You must first disconnect then change the address or it may cause some problems because one machine address can't have 2 IP addresses at the same time. (I don't know how to change it even if you disconnect... but I think you must disconnect first!)
Well... I am a beginner ...
|
|
|
|
|
This is the closest I could find on the subject (using netsh to change the interface parameters):
MSKB #257748[^]
I've never used netsh personally, but it seems like the easiest way to go.
- Mike
|
|
|
|
|
Thanks for the input, I'm sorry I didn't respond sooner. I have been feeling really lazy lately and haven't gotten around to working on it
Matt Newman Sonork: 100:11179
"Battleship, was the first game that taught you to lie" - Zachery
|
|
|
|
|
Hi again!
I found a way but as I mentiones before you will have to reboot each time you change it. ( it is registry stuff)
http://www.codeguru.com/network/change_ip.shtml
I hope this will help!
Well... I am a beginner ...
|
|
|
|
|
Thanks for the input. As I said in my response to Michael I have been really lazy lately and haven't gotten around to using it yet.
Matt Newman Sonork: 100:11179
"Battleship, was the first game that taught you to lie" - Zachery
|
|
|
|
|
How can i register an event in windows .
for example my program with pressing enter do something
and i want my program without focus do this action.
even if be in other program.
MkhProgrammer
|
|
|
|
|
Hi,
I'm using a CWinThread to send and recieve ICMP packets (pings).
but while recieving the echo replys the thread exits.
Thats the code I'm calling:
<br />
char* echoReply = new char[50];<br />
int nRet;<br />
int nAddrLen = sizeof(struct sockaddr_in);<br />
sockaddr_in lpsaFrom;<br />
lpsaFrom.sin_family = AF_INET;<br />
lpsaFrom.sin_port = 0;<br />
lpsaFrom.sin_addr.s_addr = inet_addr("192.168.6.100");<br />
<br />
nRet = recvfrom(s,<br />
echoReply,<br />
sizeof(echoReply),<br />
0,<br />
(sockaddr*) &lpsaFrom,<br />
&nAddrLen);<br />
when calling recvfrom() the thread breaks down. even the debugger does not stop at any breakpoints i have set after the recvfrom call.
has anybody an idea?
PS: recv also doesn't work and bind works fine...
|
|
|
|
|
This may not fix the problem but...
sizeof(echoReply) will return 4 (the size of the pointer), not 50. You need to specify 50 instead of sizeof(echoReply) .
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
My question is though, is standard the same as student/intro editions? Becuase I used to have a version of VC++ 6.0 that came bundled with a teach yourself programming package but the program wouldnt let me make programs stand alone so that i could give it to a friend or something.. If they wanted to use it they'd have to compile my code every time and so did i..
Is the standard edition of VC++.net the same? Should I have gotten profesional?
I'm just learning C++ so am not sure what all the information about the programs are so it's hard for me to tell the benifits and abilities.
Any help is appriciated,
thanks.
|
|
|
|
|
Anonymous wrote:
My question is though, is standard the same as student/intro editions?
No. The programs you build with the standard edition of Visual C++ .NET do not need to be compiled more than once unless you need to make changes to the program. In other words, the Standard Edition of Visual C++ .NET makes stand alone programs. Have fun!
I am using the same program to develop a quite large application being written in C++ and it does the job for me. If you have any other questions, let me know.
Sincerely,
BNEACETP
N-Tech Productions
http://www.n-tp.com/
|
|
|
|
|
greetings all.
I have a project consisting of about 20 source files.
In some the call to timeGetTime() works. In others it is an illegal identifier.
What include file do I need for this API call ?
Cheers
If sex is a pain in the ass, then you are doing it all wrong!
|
|
|
|
|
Header: Declared in Mmsystem.h; include Windows.h.
Library: Use Winmm.lib.
How about taking a look at the MSDN? (no offense )
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Thanks...no offense taken...
I have a few problems with MSDN and the C++ help files: namely that they told me that I needed a header called windows.h
The source file in question has the following includes
windows.h
windowsx.h
ddraw.h
stdio.h
(Exactly the same headers as the source file that works).
NB: noticed that the source files that use timegetTime() are all class member functions: what is going on....MSDN does not cover this one (or I can't drive it).
Cheers
If sex is a pain in the ass, then you are doing it wrong!
|
|
|
|
|
Well, if your project includes these four includes, then there's missing the mmsystem.h header file. And second, link with winmm.lib. I do it this way:
#pragma comment(lib, "winmm.lib")
But you can do it in the project options as well.
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Cheers.
I found some code that had the include winmm.lib and used that: worked fine.
Can anyone shed light on why the object source files had no problem when they had the same include statements ?
Thanks for all responses: much appreciated.;)
If sex is a pain in the ass, then you are doing it wrong!
|
|
|
|
|
Hello all .
i having some question about array size.
lets say i wanto declare this array...its an "unsigned long".
lets say i wanted it the array to have the size of "8"..
so i will declare like this :
unsigned long Data[8];
ok...lets say now.. i wanto to create a "unsigned long" array.. but i not yet sure whats the size...becoz its depends on the datas that will be key in by user...
ok.. lets say..
int arraysize;
arraysize=a+b;
(where a and b are both int keyed in by user...)
then.. how i wanto set the Data array into the size of "arraysize"??
can i do it like this :
unsigned long Data[arraysize];
i tired but..error... so i hope u guys can help me out..how to solve this problem...what should i do to set my array size according to wat the datas user keyed in?
thanks...
thong
twh81@tm.net.my
...
|
|
|
|