what 0 indicates in following line? what are other flags i can use?
server = socket(AF_UNIX, SOCK_STREAM, 0)
The best thing to do here is read the man page. This document states that the third parameter is the protocol, which in this case is SOCK_STREAM but can be others.