C++ Socket Error (new initializer expression list treated as compound expression)

Just from reading the code, I think your problem should be solved by changing the line that have caused the error with this one :

sock = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);

socket() is a function and not a class to try to instantiate it.

Make sure that you have already declared “sock” variable as an instance in your class, because I don’t see it in your function.

Leave a Comment