No.. I had my embedded board connected to the PC with a cross-over cable.. no switch.
masnu
Posts
-
Winsock problem -
Winsock problemI can see how that would happen. Thankfully this one didn't take me that much time. Try WireShark http://www.wireshark.org/[^] it's a useful tool.
-
Winsock problemI was using Wireshark, but it DID display an incorrect checksum. I just got busy doing other things and completely overlooked it. It wasn't until I focused on the problem that I paid attention to what the analyzer was telling me.
-
Winsock problemNope! It was a me problem!! :-) Thanks Moak!
-
Winsock problemFor those of you who are interested I finally figured out what the problem was. When I implemented the TCP/IP stack on the micro I made a mistake in the routine that calculates the IP header checksum. With an invalid checksum Winsock just disregarded the message. Once the correct checksum was sent everything worked fine. Thanks to all of you for your help. I appreciate it. Paul
-
Winsock problemSorry Moak, I was cutting and pasting and forgot the most important part. Here's the actual code to open and connect:
int CHPCtrl::Connect()
{struct sockaddr\_in rmtAddr;
// Create data socket
m_Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);if ( m\_Socket == INVALID\_SOCKET ) return 1;
// Set client properties
rmtAddr.sin_family = AF_INET;
rmtAddr.sin_addr.s_addr = inet_addr( remoteIP );
rmtAddr.sin_port = htons( m_nDevicePort );// Connect to remote
if ( connect( m_Socket, (struct sockaddr *)&rmtAddr, sizeof(rmtAddr) ) == SOCKET_ERROR )
return 1;// Open rx monitor thread
m_hRxMonitor = (HANDLE)_beginthreadex( 0, 0, RxMonitor, this, CREATE_SUSPENDED, 0 );if ( m\_hRxMonitor ) { m\_bConnected = true; ResumeThread( m\_hRxMonitor ); } //\_\_if ( m\_pReadThread )\_\_ return 0;
}
And in a separate thread I wait for incoming data:
UINT CHPCtrl::RxMonitor(void *pThis)
{CHPCtrl \*pCtrl = (CHPCtrl\*)pThis; int bytes\_recevied = 0; fd\_set sckt; timeval timeout;
// Set two second timeout
timeout.tv_sec = 2;
timeout.tv_usec = 0;// Monitor all rx traffic
while ( pCtrl->m_bConnected )
{FD\_ZERO( &sckt ); FD\_SET( pCtrl->m\_Socket, &sckt ); int ret = select( 0, &sckt, 0, 0, &timeout ); switch ( ret ) { case SOCKET\_ERROR: //Handle error break; case 0: //Timeout //Handle time out break; default: pCtrl->ReadFromSocket( pCtrl->m\_Socket ); } //\_\_switch ( ret )\_\_ } //\_\_while ( m\_bRunRx )\_\_
// Shutdown rx comm
shutdown( pCtrl->m_Socket, SD_RECEIVE );return 0;
}
m_Socket is a class variable. I did this so I can send and receive on the same socket without blocking. Please let me know if you see anything wrong with this.
-
Winsock problemPlease elaborate as to which part of the post wasn't in "international" English and I will be happy to clarify.
-
Winsock problemI'm not using any BSP and I implemented the TCP stack myself. I am able to establish communication via the 3-way handshaking process and then I assemble the package and send it. I used Wireshark to trap the packets between the PC and the micro and it recognizes it as a valid TCP/IP packet so I'm assuming it's formated properly.
-
Winsock problemYes I can connect to the micro and send data from the PC to the micro but not the other way around. My socket is created as follows:
// Create socket
Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);And then I wait for data:
fd_set sckt;
timeval timeout;// Set two second timeout
timeout.tv_sec = 2;
timeout.tv_usec = 0;FD_ZERO( &sckt );
FD_SET( Socket, &sckt );int nRet = select( 0, &sckt, 0, 0, &timeout );
select
always returns 0 indicating a timeout no matter how much data I send from the micro. -
Winsock problemHi, I'm trying to enable my ARM development board to communicate with a PC. I can establish a connection and send data from the PC to the micro without any issues. When I try to send data from the micro to the PC, however, my socket doesn't respond to the data. A network analyzer shows that the packet was sent and formated properly. I have tried both TCP and UDP with the same results. Has anyone come across this before? Thanks.
-
VS2005 & VS2008 DLL Compilation issuesThanks Chris. I know what the /MD and /MT switches are for. What I don't understand is why the /MD switch would work on a machine with VS2005 only and not on the other.
-
VS2005 & VS2008 DLL Compilation issuesThanks but I have already installed the VC++ 2005 and 2008 runtime libraries on the target machine. That doesn't help, though. I am developing on a Windows 7 machine. Should that make a difference?
-
VS2005 & VS2008 DLL Compilation issuesHi guys, I have VS2005 and VS2008 installed on my development machine. Whenever I develop a DLL I have to link with the
/MT
(Multi-Threaded) option if I want to use it on any other machine. If I compile the DLL on a machine with VS2005 only, however, I don't have to use the/MT
option, I can use the/MD
(Multi-Threaded DLL) and the DLL can be used on any machine. Has anyone else come across this? Is there a way to resolve this? Thanks. -
Exporting a struct from a DLLHi guys, Is it possible to export a structure from a dll without including the header file where the structure is define? For example:
/*-------------------------
mydllheader.h
------------------------------*/extern "C" __declspec(dllexport) struct MyStruct
{MyStruct() { a = 0; b = 0; } int a; int b;
}
Instead of including mydllheader.h I want to do the following:
/*-------------------------
myimportheader.h
------------------------------*/extern "C" __declspec(dllimport) struct MyStruct
I would like to use myimportheader.h in my projects that use the dll that way I can hide my structure implementation from the user. Is that possible? Thanks.
-
How to get a thread's exit codeThanks Rajesh. I appreciate the help. Paul
-
How to get a thread's exit codeHi Rajesh, I know that returning from a thread will call
_endthreadex()
but everything I have read says that "terminating a thread with a call to endthread or _endthreadex helps to ensure proper recovery of resources allocated for the thread". Is it safe to assume that returning will accomplish this? Thanks, Paul -
How to get a thread's exit codeHi guys, I'm creating a multi-threaded application using
_beginthreadex()
and_endthreadex()
. If my thread executes correctly I call_endthreadex( 0 )
but if it doesn't I call_endthreadex( _<some error code>_ )
. How can I capture the thread's exit code in the main thread? Thanks. -
Simple menu questionI need to update the check on my menu item so created a message handler to my UPDATE_COMMAND_UI event. The code is as follows:
void CSpDlg::OnUpdateShowPeak(CCmdUI *pCmdUI)
{// Update menu
pCmdUI->SetCheck( m_bShowPeakVoltage );}
The menu item does not update, however. I'm I missing something? Thanks.
-
Getting Thread Exit CodeThe exit code I want is the one I have defined as
nError
in the above example. Based on that number I can determine why the thread exited. -
Getting Thread Exit CodeI have created a worker thread to connect to a data server. The thread needs to wait a few seconds and exit if no data arrives (i.e. server is not online). I need to trap the thread exit code so my main thread can know if the workher thread terminated with an error. I have the following code:
static UINT Connect(void* p_this); UINT Connect(); UINT Client::Connect(void* p_this) { Client* pClient = (Client*)p_this; pClient->Connect(); } UINT Client::Connect() { CDataServer pServer = new CDataServer(); ........ int nError = pServer->Connect(); if ( nError != 0 ) //Error connecting to server return nError; ....... }
From the documentation I know I can useGetExitCodeThread
to get the error code but where is the best place to put this? Should I post an exit message to the main thread and read the code there? Are there any other solutions that would be better? Thanks.