Jump to content
  • Advertisement

fathom88

Member
  • Content Count

    433
  • Joined

  • Last visited

Community Reputation

180 Neutral

About fathom88

  • Rank
    Member
  1. fathom88

    Socket Reading & Select

    Tried it. I checked the return value and it's a one which indicates the checked condition was met.
  2. fathom88

    Socket Reading & Select

    I thought the value was ignored under Windows. I'll give it a try.
  3. I've defined my socket to be non-blocking. I want to monitor the socket and read when data is available. I could use the ioctlsocket (windows socket) and constantly loop to check for data. I tried to use the select call w/ a timeout to wait for data? FD_ZERO(&ReadSet); FD_SET(MySocket, &ReadSet); select(1, &ReadSet, NULL, NULL, &TimeOut); However, it always came back immediately to indicate activity. Is it just checking for readability and NOT data available for read?? My intention was to have a socket reading thread.
  4. fathom88

    LNK2019 Error

    You are right. The dll was successfully used on other development platforms. It had not been tested w/ the Visual Studio. Thanks.
  5. VC++ 7.0 I'm trying to use a dll provided by someone else. I have the header, lib, and dll files. I included the .h in my app's .cpp. Under linker->input->additional dependencies, I included the name of the lib. Under linker->general->additional lib dir, I added the path of the dll. When I compile, I get FlightXY error LNK2019: unresolved external symbol "__declspec(dllimport) long __cdecl InitPhyX(void)" (__imp_?InitPhyX@@YAJXZ) referenced in function "protected: void __thiscall CFlightXYDlg::OnPaint(void)" (?OnPaint@CFlightXYDlg@@IAEXXZ) The top of the header has this directive. #ifdef PHYX_EXPORTS #define PHYX_API_FUNC extern "C" __declspec(dllexport) #else #define PHYX_API_FUNC __declspec(dllimport) #endif What am I missing?
  6. fathom88

    CSingleLock??????

    Hello Evil Steve, It's nice to see your still on the forum! You're probably right. I haven't jumped to BOOST yet. I wish it was integrated into C++ like STL.
  7. What is the purpose CSingleLock? It can't function w/out a Mutex, Critical Section etc. I've read conflicting things about it. I read one post even said you can't use it across multiple threads??!! People have complained the underlying code is wrong. BOOL CSingleLock::Lock(DWORD dwTimeOut /* = INFINITE */) { ASSERT(m_pObject != NULL || m_hObject != NULL); ASSERT(!m_bAcquired); m_bAcquired = m_pObject->Lock(dwTimeOut); return m_bAcquired; } BOOL CSingleLock::Unlock() { ASSERT(m_pObject != NULL); if (m_bAcquired) m_bAcquired = !m_pObject->Unlock(); // successfully unlocking means it isn't acquired return !m_bAcquired; } Should I even use it?
  8. You're right! I have no idea why it was working on Linux.
  9. I have a bit of code which seems to run perfectly on Linux but seem to crash out on Windows. char * GetFilePath(char *BasePath) { std::string Path = BasePath; Path + mActiveFileNameStr; return const_cast<char*>(Path.c_str()); } The code fails when I try to use the returning char string. std::string FilePath(GetFilePath("C:\\Maps")); //crashes out here Do I need to make Path a static? Why hasn't this been an issue on Linux?
  10. I'm getting a strange error when I try to use CMutex and CSingleLock from the Visual Studio VC++. In my class I have something like this. class MyClass{ CMutex mMutex; CSingleLock *mSingleLockPtr; }; In my constructor, mSingleLockPtr = new CSingleLock(&mMutex); In my class I have a function CViewPort* GetViewPort() { mSingleLockPtr->Lock(); if(mViewPort == NULL) mViewPort = new CViewPort(); mSingleLockPtr->Unlock(); return mViewPort; } It returns the viewport and creates it if one hasn't been made. I have multiple threads running. I used the locking because I noticed sometimes multiple view ports were created and assigned to the same member. I wanted to make sure only one viewport was created. However, I get a strange error. An assertion failed in the SingleLock class. I know it's something wrong w/ the way I'm locking. When I remove it, the program runs fine even if new CViewPort gets called twice. I can't see anything obvious. It looks like one thread tries to get access once. While another one is trying multiple times. The one which tries multiple times seems to get control 1st. The 2nd thread does not seem to ever get access. However, I can't be sure because the app crashes out and go into the stack dump. Thanks in advance.
  11. fathom88

    Java Socket Read Problem

    I'm still only getting around 1 MB a sec. I've noticed if I increase the buffer too much or lower the thread sleep to zero, the amount I read actually goes down. Why would that be?
  12. fathom88

    Java Socket Read Problem

    My knee jerk reaction was to increase the buffer to 20480 and set the sleep to zero. I didn't notice a difference. I guess I could increase the buffer further. On another note, my sever app streams the 2.5 MB over the course of one sec. It does NOT send a single burst of 2.5 MB at one sec intervals.
  13. Is there a max rate Java's SocketChannel can read data at? I always assumed the max rate would be whatever your hardware connection is. In my case, it's two PC's next to each other connected by an ethernet cable. I must conclude there is a problem with my read code. My server sends 2.5 MB of data to my client every 1 sec. My client seems to take 3 or 4 sec to read the 2.5 MB of data. I'm new to using the SocketChannel and assume I'm doing something wrong. Here is my read code which gets called inside my void run() with a "Thread.sleep(1)" ByteBuffer buf = ByteBuffer.allocateDirect(1024); try { // Clear the buffer and read bytes from socket buf.clear(); int numBytesRead = socketChannel.read(buf); if (numBytesRead == -1) { // No more bytes can be read from the channel socketChannel.close(); } else { //Read bytes; currently commented out to do nothing to prevent //any slow down from processing the data } } catch (IOException e) { // Connection may have been closed } I tried to increase the read buffer. I've to set my sleep to zero. Both attempts didn't speed up the read.
  14. Is there a max rate Java's SocketChannel can read data at? I always assumed the max rate would be whatever your hardware connection is. In my case, it's two PC's next to each other connected by an ethernet cable. I must conclude there is a problem with my read code. My server sends 2.5 MB of data to my client every 1 sec. My client seems to take 3 or 4 sec to read the 2.5 MB of data. I'm new to using the SocketChannel and assume I'm doing something wrong. Here is my read code which gets called inside my void run() with a "Thread.sleep(1)" ByteBuffer buf = ByteBuffer.allocateDirect(1024); try { // Clear the buffer and read bytes from socket buf.clear(); int numBytesRead = socketChannel.read(buf); if (numBytesRead == -1) { // No more bytes can be read from the channel socketChannel.close(); } else { //Read bytes; currently commented out to do nothing to prevent //any slow down from processing the data } } catch (IOException e) { // Connection may have been closed } I tried to increase the read buffer. I've to set my sleep to zero. Both attempts didn't speed up the read.
  15. fathom88

    Java Lang Question

    Vector<Vector<Object>> DataPoints; DataPoints = new Vector<Vector<Object>>(); Good thinking. To do insertions, would I create a separate Vector object and add it my vector or vectors? Thanks.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!