Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Problem in SysSockBind

2011-08-20
2023-08-17
  • hiten.upadhyay - 2011-08-20

    I am trying to implement a TCP/IP application in codesys using the SysLibSocket.lib.
    Here is my piece of code for creating the socket and binding it. But the bind function always return False. Can any one pls help me to find out whats wrong or missing in the code.

    SocketCreateHandle := SysSockCreate(SOCKET_AF_INET, SOCKET_STREAM, 0);
    SocketAddress.sin_family := SOCKET_AF_INET ;
    InetAddr := '201.65.32.177';
    SocketAddress.sin_addr := SysSockInetAddr(InetAddr);
    SocketAddress.sin_port := SysSockHtons(3000);
    bResult := SysSockBind(SocketCreateHandle, ADR(SocketAddress), SIZEOF(SocketAddress));
    IF bResult THEN
    // here it always returns false
    END_IF

    If anyone has any sample program for implementing TCP/IP server or client in Codesys, pls share with me or any useful link would be highly appreciated.
    Thanks in advance

     
  • TimvH

    TimvH - 2011-08-20

    I think you should have posted this in the V2.3 section, because you are looking for a .lib example.
    Anyway, a very good example can be found through the website w www.3s-software.com w .
    Select the menu Download=>CoDeSys Sample Projects.
    Go to the ftp site and choose: /Projects/CoDeSysV2.3/Communication/TcpIp/

    See the pdf file and example project.

     
  • hiten.upadhyay - 2011-08-20

    Thanks for ur help.
    I tried the ftp link, but it says the link is either down or has beem moved to some other location.
    Can u pls provide me some other info about it.

     

Log in to post a comment.