what 0 indicates in following line? what are other flags i can use?
server = socket(AF_UNIX, SOCK_STREAM, 0)
As others have likely said, the third argument to socket is generally an int indicating the protocol. 0 indicates that the caller does not want to specify the protocol and will leave it up to the service provider.
Other than zero, another common one is IPPROTO_TCP.
Full details can be found on the man page using man 2 socket on your machine or visiting here.