CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Mar 2004
    Posts
    382

    TCP/IP Application

    Can anyone help me, I'm having a little trouble connecting to a host. The host in this case is a micro-controller, and it has an IP address which I know, and I want to connect to it. I've tried WinSock, but I haven't had any success with it. The micro-controller has an IP address, but no port number. I need to be able to send commands and receive a response from the micro-controller. But first, I just want to connect to it via TCP/IP. Any information you can give me would be really appreciated. Thanks.

  2. #2
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354
    Hm.. is there a winsock server running on the host ? If not, I don't see any reason why a connect will ever be successful from the client.

  3. #3
    Join Date
    Mar 2004
    Posts
    382
    It's funny you should mention that because it never crossed my mind. I've been looking into winsock for the past two days. To answer your question, no, there is no winsock server running on the micro-controller. The problem I'm having is that I haven't dealt with TCP/IP yet, so I'm not even sure where to start. I've done a search on the forum, but haven't found anything helpful so if anyone can point me in the right direction, I would really appreciate it. Thanks again.

  4. #4
    Join Date
    Mar 2002
    Location
    St. Petersburg, Florida, USA
    Posts
    12,125
    Sounds like the microcontroller is "socketless". You need to find out what protocols it actually expects...time to RTFM...
    TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
    2008, 2009,2010
    In theory, there is no difference between theory and practice; in practice there is.

    * Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
    * How NOT to post a question here
    * Of course you read this carefully before you posted
    * Need homework help? Read this first

  5. #5
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    [Moved thread]

  6. #6
    Join Date
    Mar 2004
    Posts
    382
    Manufacturere told me the micro-controller uses TCP/IP protocol. So is there no way I can connect to the micro-controller if I know the IP address only?

  7. #7
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    Originally posted by kodeguruguy
    So is there no way I can connect to the micro-controller if I know the IP address only?
    Well...you should know the port number as well...

  8. #8
    Join Date
    Jan 2002
    Location
    Scaro, UK
    Posts
    5,940
    So true. The whole point about TCP/IP (I think it's written in the protocol spec but I may be wrong) that it comes with an IP address AND a port number.

    You must know the port number to be able to communicate.

    Darwen.
    www.pinvoker.com - PInvoker - the .NET PInvoke Interface Exporter for C++ Dlls.

  9. #9
    Join Date
    Feb 2003
    Location
    BeiJing China
    Posts
    290
    run a server is necessary if you use the socket to communicate i think .

    and normally, the server is binded to its ip & port, and waiting to recv connection to it.

    wxuf
    Waiting OFFERS from CMU, UMass, UC Davis, OSU
    Mail to me

  10. #10
    Join Date
    Mar 2004
    Posts
    382
    First off, I want to say thanks to everyone for their response. I just got off the phone with the manufacturer and got the port number for this micro-controller. So now I got the IP address and the port number, so I should be able to communicate with it with Winsock right? Anyone know where I can find a simple code for reference, or any tutorials? I've never worked with Winsock before.

  11. #11
    Join Date
    Apr 2004
    Posts
    13
    Hello:
    I was in the same trouble about starting programming winsock, i can give you those links, they are very clear in connecting and accepting connections...in your case you only have to create a socket with the ip and port and if the server accept you, you can start sending and receiving data ...

    Here are the links:

    http://tangentsoft.net/wskfaq/exampl...ed-server.html

    http://www.codeproject.com/internet/winsockintro01.asp

    Well, one more thing: if you want to use MFC you can check the doucmentacion for the CAsyncSocket and CSocket classes, they encapsulate winsock at a higher level....

    Greetings

  12. #12
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    Originally posted by kodeguruguy
    Anyone know where I can find a simple code for reference, or any tutorials? I've never worked with Winsock before.
    Winsock Programmer's FAQ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured