Search code examples
iosobjective-csocketsircasyncsocket

IRC /TOPIC command trimming issue in iOS


I am using Cocoa async socket library in my iOS application to make connection with an IRC server via Tcp sockets. All the IRC commands are working perfectly except /TOPIC command. When I send a topic command it always trim the first two characters in the response. Please check the example wireshark report below.

Request

Response

It works on other IRC clients (mIRC). How can I identify the root cause of the issue?


Solution

  • If you send your own IRC commands (most IRC clients let you easily inject arbitrary commands with /command here), you have to format it correctly, with a : before the final parameter if it contains spaces:

    TOPIC #abcdereh :My name is Clement
    

    Most IRC clients have an alias for /TOPIC that does that stuff for you.
    If you are writing your own client, make sure that you handle the following cases:

    • /TOPIC: send TOPIC #currentchannel
    • /TOPIC #somechannel send TOPIC #somechannel
    • /TOPIC Not a channel send TOPIC #currentchannel :Not a channel
    • /TOPIC #somechannel New Topic send TOPIC #somechannel :New Topic